diff --git a/audio/Melodies/bassline.py b/audio/Melodies/bassline.py new file mode 100644 index 0000000..873bcf9 --- /dev/null +++ b/audio/Melodies/bassline.py @@ -0,0 +1,352 @@ +import random +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) + +import pyaudio + +from Oscillators.sine_osc import SineOsc + +sine_osc = SineOsc() + +p = pyaudio.PyAudio() +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + frames_per_buffer=6615) + + +def bassline(): + frequency = random.choice([70, 70, 62, 74]) + other_melody = frequency*5 + volume = .05 + length = .1 + for i in range(2): + sine_osc.play_frequencies( + stream, + length, + volume, + random.choice([100]), + random.choice([100]), + other_melody, + other_melody + 3, + other_melody - 3, + other_melody + 5, + other_melody - 5, + other_melody + 10, + other_melody - 10, + other_melody + 6, + other_melody - 6, + other_melody/2, + ) + + random.choice([ + sine_osc.play_frequencies( + stream, + length, + .1, + random.choice([200]), + random.choice([200]), + other_melody, + other_melody *11/8, + other_melody/3, + other_melody/4,), + sine_osc.play_frequencies( + stream, + length, + .15, + random.choice([200]), + random.choice([200]), + other_melody/3, + ), + ]) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody, + other_melody *11/8, + other_melody/3, + other_melody/4, + + random.choice([frequency * 5, + frequency * 5/2 * 5, + frequency * 7 / 4 * 5]) + ) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody, + other_melody *3/2, + other_melody/4, + ) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 7/6, + ) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + frequency, + frequency / 2, + ) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + frequency, + frequency / 3, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 2, + other_melody * 4/3 + ) + + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 3/2, + other_melody * 5/4, + other_melody * 3/2 / 2, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 3/2, + other_melody * 5/4, + other_melody * 3/2 / 2, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + frequency, + frequency / 3, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 2, + other_melody * 4/3 + ) + + # good ___ + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 3/2, + other_melody * 5/4, + other_melody * 3/2 / 2, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 3/2, + other_melody * 5/4, + other_melody * 3/2 / 2, + ) + sine_osc.play_frequencies( + stream, + length, + volume, + random.choice([100]), + random.choice([100]), + other_melody, + other_melody + 3, + other_melody - 3, + other_melody + 5, + other_melody - 5, + other_melody + 10, + other_melody - 10, + other_melody + 6, + other_melody - 6, + other_melody/2, + ) + + random.choice([ + sine_osc.play_frequencies( + stream, + length, + .1, + random.choice([200]), + random.choice([200]), + other_melody, + other_melody *11/8, + other_melody/3, + other_melody/4,), + sine_osc.play_frequencies( + stream, + length, + .15, + random.choice([200]), + random.choice([200]), + other_melody/3, + ), + ]) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody, + other_melody *11/8, + other_melody/3, + other_melody/4, + + random.choice([frequency * 5, + frequency * 5/2 * 5, + frequency * 7 / 4 * 5]) + ) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody, + other_melody *3/2, + other_melody/4, + ) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 7/6, + ) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + frequency, + frequency / 2, + ) + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + frequency, + frequency / 3, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 2, + other_melody * 4/3 + ) + # good ___ + + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 3/2, + other_melody * 5/4, + other_melody * 3/2 / 2, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 3/2, + other_melody * 5/4, + other_melody * 3/2 / 2, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + frequency, + frequency / 3, + ) + sine_osc.play_frequencies( + stream, + .1, + .1, + random.choice([200]), + random.choice([200]), + other_melody * 2, + other_melody * 4/3 + ) + + for i in range(400, 440): + sine_osc.play_frequencies( + stream, + .01, + .29, + 200, + 200, + i + ) + + +if __name__ == '__main__': + bassline() + + + + diff --git a/audio/Melodies/cleek.py b/audio/Melodies/cleek.py new file mode 100644 index 0000000..ebfff28 --- /dev/null +++ b/audio/Melodies/cleek.py @@ -0,0 +1,40 @@ +import random +import time +import pyaudio +from Oscillators.sine_osc_cleek import SineOsc + +sine_osc = SineOsc() +p = pyaudio.PyAudio() + +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + ) + + +def cleek(freq, length, vol): + sine_osc.play_frequencies(stream, + length, + vol * .2, + 2000, + 2000, + random.choice([freq / 2 + 20, freq / 2, -30, freq / 2 + 100, freq / 2]), + # freq, + # freq, + # freq * 22/8, + # freq * 15/8, + # freq * 27/8, + random.choice([freq * 3, freq * 15/4, freq * 36/8]), + ) + +frequency = 200 +for i in range(100): + cleek( + frequency, + random.choice([.15, .2, .15, .5, .15, .3, 1]), + random.choice([1, 1, 0, 0, 0]) + ) + frequency += random.choice([10, -10, 30, -30, 10, 25, -25]) + +time.sleep(.5) diff --git a/audio/Melodies/dad.py b/audio/Melodies/dad.py new file mode 100644 index 0000000..1be30b0 --- /dev/null +++ b/audio/Melodies/dad.py @@ -0,0 +1,203 @@ +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) +import time +import random +import pyaudio +from Oscillators.sine_osc import SineOsc + +sine_osc = SineOsc() + +p = pyaudio.PyAudio() +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + ) + + +def idea(freq, tempo): + sine_osc.play_frequencies(stream, tempo, .7, 800, 200, + freq, + freq, + freq * 3/2, + freq * 3/2, + freq * 3/2, + freq * 3/2 + 3, + freq * 3/2 - 3, + freq * 3/2 + 2, + freq * 3/2 - 2, + # freq * 3/2 + 9, + # freq * 3/2 - 9 + # ) + ) + + +def idea_2(freq, tempo): + sine_osc.play_frequencies(stream, tempo, .09 / 2, 10000*tempo, 20000*tempo, + freq /4 - 2, + freq /4 - 2, + freq /4 + 2, + freq /2, + freq /2 - 2, + freq /2 + 2, + freq /2 + 2, + freq /2 * 3, + freq /2 * 3, + freq, + freq * 3/2, + freq * 3/2 - 3.2, + freq * 3/2 + 3.2, + freq * 5/4, + freq * 3/2 - 2, + freq * 9/4 + 2, + freq * 9/2, + freq * 30/8, + freq * 30/8 - 3.2, + freq * 36/8 + 3.2, + freq * 20/4, + freq * 23/4, + freq * 23/4 + 3.2, + freq * 33/8, + freq * 44/8 + ) + +if __name__ == '__main__': + freq = 131 + idea_2(freq, 3) + # time.sleep(20) + freq = freq * 5/6 + idea_2(freq, 2) + idea_2(freq * 9/8, 2) + # time.sleep(60) + idea_2(143, 2) + # time.sleep(20) + idea_2(131, 8) + freq = 196 + idea_2(freq, 3) + idea_2(freq * 8/9, 1) + idea_2(freq * 3/4, 1) + idea_2(131, 2) + idea_2(120, 2) + idea_2(140, 2) + idea_2(155, 1) + idea_2(138, 1) + idea_2(131, 2) + idea_2(131, 2) + idea_2(131, 6) + freq = 740 + idea_2(freq, 3) + freq = 131 + idea_2(freq * 3/2,8) + idea_2(freq, 4) + time.sleep(4) + idea_2(freq * 4/3, 4) + idea_2(freq,9) + + freq = 740 + idea_2(freq, 3) + freq = 131 + idea_2(freq * 3/2,8) + idea_2(freq, 5) + time.sleep(5.5) + idea_2(freq * 4/3, 4) + idea_2(freq,10) + + time.sleep(37) + + freq = 740 + idea_2(freq, 3) + freq = 131 + idea_2(freq * 3/2, 10) + idea_2(freq, 8) + time.sleep(4) + # idea_2(freq * 4/3, 4) + # idea_2(freq,10) + + + + + # # time.sleep(10) + # idea_2(131, 20) + # # time.sleep(20) + # idea_2(131, 40) + # time.sleep(.5) + +# for i in range(4): +# freq = 190 +# for i in range(3): +# freq += random.choice([-6, -10, -20, -30, 20]) +# freq2 = 190 +# for i in range(13): +# idea(freq2, .045) +# freq2 += 14 +# idea(freq, 1.2) +# for i in range(22): +# idea(freq2, .03) +# freq2 -= 13.9 +# for i in range(30): +# idea(freq2, .022) +# freq2 += 3 +# for i in range(18): +# idea(freq2, .02) +# freq2 -= 3 +# for i in range(20): +# idea(freq2, .02) +# freq2 += 3 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 4 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 3 +# for i in range(5): +# idea(freq2, .02) +# freq2 -= 4 +# for i in range(5): +# idea(freq2, .02) +# freq2 += 5 +# for i in range(4): +# idea(freq2, .02) +# freq2 -= 4 +# for i in range(4): +# idea(freq2, .02) +# freq2 += 4 +# +# for i in range(20): +# idea(freq2, .02) +# freq2 -= 1 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 2 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 2 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 2 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 9 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 7 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 8 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 7 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 8 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 7 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 12 + +# idea_2(190, 8) +# idea_2(180, 8) +# idea_2(170, 8) +# idea_2(160, 8) diff --git a/audio/Melodies/emily.py b/audio/Melodies/emily.py new file mode 100644 index 0000000..a0b4ea7 --- /dev/null +++ b/audio/Melodies/emily.py @@ -0,0 +1,159 @@ +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) +import time +import random +import pyaudio +from Oscillators.sine_osc import SineOsc + +sine_osc = SineOsc() + +p = pyaudio.PyAudio() +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + ) + + +def idea(freq, tempo): + sine_osc.play_frequencies(stream, tempo, .7, 800, 200, + freq, + freq, + freq * 3/2, + freq * 3/2, + freq * 3/2, + freq * 3/2 + 3, + freq * 3/2 - 3, + freq * 3/2 + 2, + freq * 3/2 - 2, + # freq * 3/2 + 9, + # freq * 3/2 - 9 + # ) + ) + + +def idea_2(freq, tempo): + sine_osc.play_frequencies(stream, tempo, .09, 500000, 800000, + freq /4 - 2, + freq /4 - 2, + freq /4 + 2, + freq /2, + freq /2 - 2, + freq /2 + 2, + freq /2 + 2, + freq /2 * 3, + freq /2 * 3, + freq, + freq * 3/2, + freq * 3/2 - 3.2, + freq * 3/2 + 3.2, + freq * 5/4, + freq * 3/2 - 2, + freq * 9/4 + 2, + freq * 9/2, + freq * 30/8, + freq * 30/8 - 3.2, + freq * 36/8 + 3.2, + freq * 20/4, + freq * 23/4, + freq * 23/4 + 3.2, + freq * 33/8, + freq * 44/8 + ) + +if __name__ == '__main__': + # time.sleep(50) + idea_2(131, 45) + # time.sleep(20) + idea_2(131, 45) + # time.sleep(60) + idea_2(143, 45) + # time.sleep(20) + idea_2(131, 45) + # time.sleep(20) + idea_2(196, 50) + # time.sleep(10) + idea_2(131, 45) + # time.sleep(20) + idea_2(131, 40) + # time.sleep(.5) + +# for i in range(4): +# freq = 190 +# for i in range(3): +# freq += random.choice([-6, -10, -20, -30, 20]) +# freq2 = 190 +# for i in range(13): +# idea(freq2, .045) +# freq2 += 14 +# idea(freq, 1.2) +# for i in range(22): +# idea(freq2, .03) +# freq2 -= 13.9 +# for i in range(30): +# idea(freq2, .022) +# freq2 += 3 +# for i in range(18): +# idea(freq2, .02) +# freq2 -= 3 +# for i in range(20): +# idea(freq2, .02) +# freq2 += 3 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 4 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 3 +# for i in range(5): +# idea(freq2, .02) +# freq2 -= 4 +# for i in range(5): +# idea(freq2, .02) +# freq2 += 5 +# for i in range(4): +# idea(freq2, .02) +# freq2 -= 4 +# for i in range(4): +# idea(freq2, .02) +# freq2 += 4 +# +# for i in range(20): +# idea(freq2, .02) +# freq2 -= 1 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 2 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 2 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 2 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 9 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 7 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 8 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 7 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 8 +# for i in range(10): +# idea(freq2, .02) +# freq2 -= 7 +# for i in range(10): +# idea(freq2, .02) +# freq2 += 12 + +# idea_2(190, 8) +# idea_2(180, 8) +# idea_2(170, 8) +# idea_2(160, 8) diff --git a/audio/Melodies/ian.py b/audio/Melodies/ian.py new file mode 100644 index 0000000..347af4f --- /dev/null +++ b/audio/Melodies/ian.py @@ -0,0 +1,80 @@ +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) + +import random +import time +import pyaudio +from Oscillators.sine_osc_patrick import SineOscPatrick + +sine_osc = SineOscPatrick() + +p = pyaudio.PyAudio() +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + ) + + +def one(freq, length, vol): + sine_osc.play_frequencies(stream, length, vol, 8000, 5000, + random.choice([freq * 1/2]), + freq / 2, + freq, + freq * 3/2 + 2 * 2, + random.choice([freq * 10/4]), + ) + + +def three(freq, length, vol): + sine_osc.play_frequencies(stream, length, vol, 2000, 2000, + random.choice([50, 65, 50, 70, 50, 68]), + freq / 2, + freq, + freq * 3, + ) + +def two(freq, length, vol): + for j in range(2): + one(freq, length, vol) + for j in range(2): + one(freq * 2, length, vol) + melody = random.choice([120, 130, 140, 150]) + for j in range(6): + one(melody, .2, vol) + melody += random.choice([-2, -3]) + +if __name__ == '__main__': + for k in range(4): + freq = 100 + vol = 0 + for j in range(180): + if j < 30: + vol += .06 + three(freq, .05, vol) + if j > 120: + vol -= .03 + freq += random.choice([-10, 12, -9, 13, -8, 14]) + + for i in range(6): + two(206, 1, 1) + + time.sleep(60) + + + for k in range(2): + freq = 100 + vol = 0 + for j in range(180): + if j < 30: + vol += .06 + three(freq, .05, vol) + if j > 120: + vol -= .03 + freq += random.choice([-10, 12, -9, 13, -8, 14]) + + for i in range(6): + two(206, 1, 1) + + time.sleep(.5) diff --git a/audio/Melodies/lorenzo.py b/audio/Melodies/lorenzo.py new file mode 100644 index 0000000..c19433c --- /dev/null +++ b/audio/Melodies/lorenzo.py @@ -0,0 +1,162 @@ +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) + +import random +import time +import pyaudio +from Oscillators.sine_osc import SineOsc + +sine_osc = SineOsc() + +p = pyaudio.PyAudio() +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + ) + + +def one(freq, length, vol, subdivision=1): + for i in range(subdivision): + sine_osc.play_frequencies(stream, (length / subdivision) * .95, vol * random.choice([.4, .5, .6, .7, .8, .9, 1, 1 ,1]), 1000, 1000, + freq / 4, + freq / 4, + freq / 4 + 5, + freq / 2 - 5, + freq / 2 + 3, + freq - 2, + freq * 2 + 2, + freq * 4, + random.choice([freq * 5/4, freq * 8/7, freq * 9/8, freq * 3/4, freq * 3/2, freq * 11/8]), + random.choice([freq * 5/4, freq * 8/7, freq * 9/8, freq * 3/4, freq * 3/2, freq * 3/2 / 2]), + random.choice([freq * 5/4, freq * 8/7, freq * 9/8, freq * 3/4, freq * 3/2, freq * 5/4 / 2]), + random.choice([freq * 5/4, freq * 8/7, freq * 9/8, freq * 3/4, freq * 3/2, freq * 5/4 / 2]), + random.choice([freq * 5/4, freq * 8/7, freq * 9/8, freq * 3/4, freq * 3/2, freq * 5/4 / 2]), + random.choice([freq * 5/4 * 2, freq * 8/7 * 2, freq * 9/8 * 2, freq * 3/4 * 2, freq * 3/2 * 2, freq * 5/4 * 2]), + random.choice([freq * 5/4 * 2, freq * 8/7 * 2, freq * 9/8 * 2, freq * 3/4 * 2, freq * 3/2 * 2, freq * 5/4 * 2]), + ) + + +def three(freq, length, vol): + sine_osc.play_frequencies(stream, length, vol, 2000, 2000, + random.choice([50, 65, 50, 70, 50, 68]), + freq / 2, + freq, + freq * 3, + ) + +def two(freq, length, vol): + for j in range(2): + one(freq, length, vol) + for j in range(2): + one(freq * 2, length, vol) + melody = random.choice([120, 130, 140, 150]) + for j in range(6): + one(melody, .2, vol) + melody += random.choice([-2, -3]) + +if __name__ == '__main__': + tempo = .8 + vol = .5 + freq = 392 + one(freq, tempo * 0.8, vol, 10) + one(freq * 9/8, tempo * 2.2, vol, 20) + one(freq, tempo, vol, 8) + one(freq * 4/3, tempo * 2, vol, 20) + one(freq * 5/3, tempo * 2, vol, 20) + one(freq * 3/2, tempo, vol, 15) + one(freq * 5/4, tempo * 5, vol, 50) + time.sleep(tempo * 2) + + one(freq * 2, tempo * 3, vol, 20) + one(freq * 4/3, tempo * 1, vol, 8) + one(freq * 15/8, tempo * 2, vol, 20) + one(freq * 5/3, tempo * 2, vol, 20) + one(freq * 3/2, tempo * 3, vol, 20) + time.sleep(tempo * 1) + + time.sleep(tempo * 1) + one(freq * 5/3, tempo * 1, vol, 8) + one(freq * 5/4, tempo * .65, vol, 6) + one(freq * 9/8, tempo * .3, vol) + one(freq * 1, tempo * .6, vol, 6) + one(freq * 5/4, tempo * .37, vol, 6) + + one(freq * 4/3, tempo * 1.5, vol, 14) + one(freq * 1, tempo * .5, vol, 5) + one(freq * 5/3, tempo * 1.5, vol, 13) + one(freq * 3/2, tempo * .28, vol) + one(freq * 4/3, tempo * .22, vol, 5) + one(freq * 5/3, tempo * 1.5, vol, 17) + one(freq * 3/2, tempo * .27, vol, 5) + one(freq * 4/3, tempo * .23, vol, 5) + one(freq * 7/6, tempo * .5, vol, 9) + one(freq * 1, tempo * 1.5, vol, 18) + + one(freq * 5/3, tempo * 1, vol, 13) + one(freq * 3/2, tempo * .5, vol, 6) + one(freq * 4/3, tempo * .5, vol, 14) + one(freq * 5/4, tempo * .75, vol, 9) + time.sleep(.25) + one(freq * 1, tempo * 4, vol, 35) + + one(freq * 1, tempo * .5, vol, 10) + one(freq * 9/8, tempo * .5, vol, 12) + one(freq * 5/4, tempo * 1, vol, 16) + one(freq * 3/2, tempo * 1, vol, 15) + one(freq * 5/4, tempo * .5, vol, 6) + one(freq * 9/8, tempo * .5, vol, 7) + one(freq * 1, tempo * .5, vol, 8) + one(freq * 5/3 /2, tempo * .5, vol, 9) + one(freq * 3/2 /2, tempo * 1, vol, 10) + one(freq * 4/3, tempo * 1, vol, 15) + one(freq * 5/4, tempo * 1, vol, 10) + one(freq * 9/8, tempo * 1, vol, 8) + + freq = freq - (freq * 9/8) + freq = freq * 3/2 + + one(freq * 1, tempo * 4, vol, 11) + one(freq * 4/3, tempo * 5, vol, 14) + one(freq * 3/2, tempo * 4, vol, 13) + one(freq * 1, tempo * 4, vol, 11) + print('a') + one(freq * 1, tempo * 6, vol, 14) + one(freq * 4/3, tempo * 5, vol, 14) + one(freq * 1, tempo * 7, vol, 23) + + print('b') + one(freq * 4/3, tempo * 7, vol, 18) + one(freq * 1, tempo * 9, vol, 24) + + print('c') + one(freq * 4/3, tempo * 7, vol, 18) + one(freq * 4/3, tempo * 7, vol, 22) + one(freq * 1, tempo * 6, vol, 23) + one(freq * 1, tempo * 4, vol, 19) + print('d') + one(freq * 3/2, tempo * 4, vol, 13) + one(freq * 3/2, tempo * 4, vol, 13) + + one(freq * 1, tempo * 5, vol, 11) + + one(freq * 0, tempo * 5, vol) + + + +# one(freq * 1, tempo * 5, vol, 15) +# one(freq * 4/3, tempo * 3, vol, 14) +# one(freq * 3/2, tempo * 3, vol, 11) +# +# one(freq * 1, tempo * 4, vol, 14) +# one(freq * 4/3, tempo * 3, vol, 14) +# one(freq * 3/2, tempo * 3, vol, 13) +# +# one(freq * 1, tempo * 5, vol, 11) +# one(freq * 4/3, tempo * 3, vol, 14) +# one(freq * 3/2, tempo * 3, vol, 13) +# +# one(freq * 1, tempo * 5, vol, 11) +# +# one(freq * 0, tempo * 5, vol) diff --git a/audio/Melodies/patrick.py b/audio/Melodies/patrick.py index 478ec9f..42d1136 100644 --- a/audio/Melodies/patrick.py +++ b/audio/Melodies/patrick.py @@ -1,9 +1,13 @@ +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) + import random import time import pyaudio -from Oscillators.sine_osc import SineOsc +from Oscillators.sine_osc_patrick import SineOscPatrick -sine_osc = SineOsc() +sine_osc = SineOscPatrick() p = pyaudio.PyAudio() stream = p.open(format=pyaudio.paFloat32, @@ -14,6 +18,7 @@ def patrick(freq, length, vol): + vol = vol / 2 sine_osc.play_frequencies(stream, length, vol, 5000, 2000, random.choice([50, 65, 50, 70, 50, 68]), # freq / 3 * 2, @@ -26,12 +31,90 @@ def patrick(freq, length, vol): def patrick_2(freq, length, vol): + vol = vol / 2 + + sine_osc.play_frequencies(stream, length, vol, 7000, 1800, + freq, + freq * 3/2 + ) + + +def patrick_3(freq, length, vol): + vol = vol / 2 + + sine_osc.play_frequencies(stream, length, vol, 400, 2000, + freq, + freq * 2, + freq /2, + ) sine_osc.play_frequencies(stream, length, vol, 2000, 2000, freq, freq * 3/2 ) +def sound(): + vol = .03 + x = random.choice([4, 3, 2, 3, 4, 5, 4, 5]) * 2 + for i in range(x): + sine_osc.play_frequencies(stream, random.choice([.05, .05, .06, .08]), vol, 400, 400, + 160, + 800, + 1100, + 1110, + 1125, + 1300, + 1325, + 2000, + 2010, + 2500, + 2505, + 2510, + 3100, + 3200, + 4000, + 4005, + 4500, + 4700, + ) + vol += .14 +for j in range(20): + bass = 100 + + for i in range(160): + if bass < 100: + bass = random.choice([150, 120, 100]) + if bass > 250: + bass = 50 + vol = random.choice( + [.2, .3, .4, + .5, .5, .5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) * 3 + x = random.choice( + [1, 1, + 2, 2, 2, + 3, 3, 3, 3]) + if x == 1: + patrick(bass, random.choice([.16]), vol / 2) + elif x == 2 : + patrick_3(50, .16, vol * .2) + else: + patrick_2(random.choice([70, 60]), .16, vol) + + rand = random.choice( + [1, 10, 25, 30, + -1, -20, -30, -50, -50, -60, -80, -110]) + bass += rand + + sound() + + for i in range(3): + patrick_3(bass, random.choice([.16]), 0) + + time.sleep(.16 * 12) + + for i in range(4): + patrick(bass, random.choice([.16]), 0) for j in range(2): for i in range(80): @@ -69,5 +152,4 @@ def patrick_2(freq, length, vol): # # bass = 200 - time.sleep(.5) diff --git a/audio/Melodies/pretty.py b/audio/Melodies/pretty.py new file mode 100644 index 0000000..c05363f --- /dev/null +++ b/audio/Melodies/pretty.py @@ -0,0 +1,223 @@ +import random +import pyaudio +from Oscillators.sine_osc import SineOsc + +sine_osc = SineOsc() + +p = pyaudio.PyAudio() +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + ) + + +def pretty(freq, tempo): + sine_osc.play_frequencies(stream, tempo, .09, 200, 200, + freq - 5, freq + 4) + sine_osc.play_frequencies(stream, tempo*2, .04, 200, 200, + freq * 15/8, + freq * 9/8, + freq,) + sine_osc.play_frequencies(stream, tempo*3, .05, 200, 200, + freq * 3/2, + freq /2 * 6/7, + ) + sine_osc.play_frequencies(stream, tempo*2, .05, 200, 200, + freq/3, freq * 5/4, + ) + sine_osc.play_frequencies(stream, tempo*3, .051, 200, 200, + freq * 9/8, + freq/4, + freq * 9/8 + 1, + ) + + +def cascade(): + print('cascade') + for i in range(0, 4): + pretty(420, .02) + for i in range(0, 4): + pretty(400, .02) + + for i in range(0, 4): + pretty(420, .02) + for i in range(0, 4): + pretty(400, .02) + + for i in range(0, 4): + pretty(440, .02) + for i in range(0, 4): + pretty(440, .02) + + for i in range(0, 4): + pretty(500, .02) + for i in range(0, 2): + pretty(490, .02) + for i in range(0, 4): + pretty(450, .02) + + +def pretty2(freq, tempo): + print('pretty3') + sine_osc.play_frequencies(stream, tempo, .09, 200, 200, + freq - 5, freq + 4) + sine_osc.play_frequencies(stream, tempo * 2, .12, 200, 200, + freq * 15 / 8, + freq * 9 / 8, + freq, ) + sine_osc.play_frequencies(stream, tempo * 3, .08, 200, 200, + freq * 3 / 2, + freq / 2 * 6 / 7, + ) + sine_osc.play_frequencies(stream, tempo * 2, .08, 200, 200, + freq / 3, freq * 5 / 4, + ) + + +def pretty3(freq): + print('pretty3') + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + freq * 9 / 8, + freq / 4, + freq * 9 / 8 + 1, + ) + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + freq * 21 / 17, + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + ) + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + ) + sine_osc.play_frequencies(stream, 1.5, .051, 200, 2000, + freq * 26 / 17, + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + ) + sine_osc.play_frequencies(stream, random.choice([.5, .8]), .051, 200, 2000, + freq * 31 / 17, + freq * 13 / 8, + freq * 13 / 8 + 1, + freq * 11 / 8, + freq * 11 / 8 + 1, + freq * 3 / 2 / 4, + ) + + +def pretty4(freq): + print('pretty4') + + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + freq * 9 / 8, + freq / 4, + freq * 9 / 8 + 1, + ) + pretty(300, .005) + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + freq * 21 / 17, + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + ) + + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + ) + pretty(300, .005) + sine_osc.play_frequencies(stream, 1.5, .051, 200, 2000, + freq * 26 / 17, + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + ) + + sine_osc.play_frequencies(stream, random.choice([.5, .8]), .051, 200, 2000, + freq * 31 / 17, + freq * 13 / 8, + freq * 13 / 8 + 1, + freq * 11 / 8, + freq * 11 / 8 + 1, + freq * 3 / 2 / 4, + ) + pretty(500, .05) + +def pretty5(freq, highest): + print('pretty4') + + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + freq * 9 / 8, + freq / 4, + freq * 9 / 8 + 1, + highest + ) + pretty(300, .005) + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + freq * 21 / 17, + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + highest + ) + + sine_osc.play_frequencies(stream, 3, .051, 200, 2000, + + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + highest + ) + pretty(300, .005) + sine_osc.play_frequencies(stream, 1.5, .051, 200, 2000, + freq * 26 / 17, + freq * 9 / 8, + freq * 9 / 8 + 1, + freq / 4, + ) + + sine_osc.play_frequencies(stream, random.choice([.5, .8]), .051, 200, 2000, + freq * 31 / 17, + freq * 13 / 8, + freq * 13 / 8 + 1, + freq * 11 / 8, + freq * 11 / 8 + 1, + freq * 3 / 2 / 4, + ) + pretty(500, .05) + + +def super_cascade(): + for i in range(0, 4): + pretty(450, .02) + for i in range(0, 1): + pretty(300, .02) + for i in range(0, 1): + pretty(250, .02) + for i in range(0, 4): + pretty(450, .02) + + for i in range(0, 1): + pretty(250, .02) + for i in range(0, 1): + pretty(300, .02) + for i in range(0, 4): + pretty(450, .02) + + for i in range(0, 1): + pretty(500, .02) + for i in range(0, 4): + pretty(650, .02) + for i in range(0, 1): + pretty(700, .02) + for i in range(0, 4): + pretty(850, .02) + +# cascade() diff --git a/audio/Melodies/sounds.py b/audio/Melodies/sounds.py new file mode 100644 index 0000000..8d04fc4 --- /dev/null +++ b/audio/Melodies/sounds.py @@ -0,0 +1,18 @@ +import random +import pyaudio +from Oscillators.sine_osc import SineOsc + +sine_osc = SineOsc() + +p = pyaudio.PyAudio() +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + ) + + +# sine_osc.play_frequencies(stream, 2, 1, 200, 200, +# 400, +# ) +# diff --git a/audio/Oscillators/sine_osc.py b/audio/Oscillators/sine_osc.py index 7a6cc8e..b1cc9ca 100644 --- a/audio/Oscillators/sine_osc.py +++ b/audio/Oscillators/sine_osc.py @@ -1,7 +1,9 @@ from __future__ import division from math import pi import numpy as np -# import matplotlib.pyplot as plt +# from Filters.butter_bandpass_filter import butter_bandpass_filter +import random +import matplotlib.pyplot as plt class SineOsc: @@ -18,9 +20,18 @@ def wave(self, frequency, length, rate): rounded_waveform = np.round(waveform, 1) waveform2 = np.power(waveform, 3) - waveform3 = np.power(rounded_waveform, 4)/4 + waveform3 = np.power(rounded_waveform, 4) - return np.add(waveform, np.add(waveform, waveform2)) + # return np.add(waveform, np.add(waveform, waveform2)) + # pre_filtered = np.add(waveform, waveform3) + # pre_filtered = np.add(pre_filtered, waveform2) + + # filtered = butter_bandpass_filter(pre_filtered, frequency, 2000, 44100, order=5) + + # return pre_filtered + onetwo = np.add(waveform, waveform2) + + return np.add(onetwo, waveform3) def play_frequencies(self, stream, length, volume, attack, decay, *freqs): """Plays a group of frequencies""" @@ -28,25 +39,36 @@ def play_frequencies(self, stream, length, volume, attack, decay, *freqs): all_tones = [] for freq in freqs: - # if freq > 1000: - # volume *= .80902 + if freq > 1000: + volume = volume * .80902 chunks = [self.wave(freq, length, self.sample_rate)] - chunk = np.concatenate(chunks) * volume - attack = attack - decay = decay + if freq > 3000: + volume *= .92 + # chunks = butter_bandpass_filter(chunks, freq, random.choice([3000, 4000]), 44100, order=5) + # + chunk = np.concatenate(chunks) * volume fade_in = np.arange(0., 1., 1./attack) fade_out = np.arange(1., 0., -1./decay) + first_noise = np.random.normal(0, .0045, len(chunk[:attack])) + second_noise = np.random.normal(0, .0045, len(chunk[-decay:])) + + in_noise = np.multiply(first_noise, np.flipud(fade_in)) + out_noise = np.multiply(second_noise, np.flipud(fade_out)) + + chunk[:attack] = np.add(chunk[:attack], in_noise) + chunk[-decay:] = np.add(chunk[-decay:], out_noise) + chunk[:attack] = np.multiply(chunk[:attack], fade_in) chunk[-decay:] = np.multiply(chunk[-decay:], fade_out) all_tones.append(chunk) chunk = sum(all_tones) - - # plt.plot(chunk[]) + # + # plt.plot(chunk) # plt.show() stream.write(chunk.astype(np.float32).tostring()) diff --git a/audio/Oscillators/sine_osc_cleek.py b/audio/Oscillators/sine_osc_cleek.py new file mode 100644 index 0000000..2b99994 --- /dev/null +++ b/audio/Oscillators/sine_osc_cleek.py @@ -0,0 +1,71 @@ +from __future__ import division +from math import pi +import numpy as np +# from Filters.butter_bandpass_filter import butter_bandpass_filter +import random +import matplotlib.pyplot as plt + + +class SineOsc: + def __init__(self): + self.sample_rate = 44100 + + def wave(self, frequency, length, rate): + """produces sine across np array""" + + length = int(length * rate) + factor = float(frequency) * (pi * 2) / rate + waveform = np.sin(np.arange(length) * factor) + + # rounded_waveform = np.round(waveform, 0) + + # waveform2 = np.power(waveform, 3) + # waveform3 = np.power(rounded_waveform, 4) + # + # pre_filtered = np.add(waveform, waveform3) + # pre_filtered = np.add(pre_filtered, waveform2) + + # filtered = butter_bandpass_filter(pre_filtered, frequency, 2000, 44100, order=5) + + # return pre_filtered + return waveform + + def play_frequencies(self, stream, length, volume, attack, decay, *freqs): + """Plays a group of frequencies""" + # volume *= .25 + all_tones = [] + + for freq in freqs: + # if freq > 1000: + # volume *= .3 + chunks = [self.wave(freq, length, self.sample_rate)] + # + # if freq < 100: + # volume *= 1 + # chunks = butter_bandpass_filter(chunks, freq, random.choice([3000, 4000]), 44100, order=5) + + chunk = np.concatenate(chunks) * volume + + fade_in = np.arange(0., 1., 1./attack) + fade_out = np.arange(1., 0., -1./decay) + + # first_noise = np.random.normal(0, .0045, len(chunk[:attack])) + # second_noise = np.random.normal(0, .0045, len(chunk[-decay:])) + + # in_noise = np.multiply(first_noise, np.flipud(fade_in)) + # out_noise = np.multiply(second_noise, np.flipud(fade_out)) + + # chunk[:attack] = np.add(chunk[:attack], in_noise) + # chunk[-decay:] = np.add(chunk[-decay:], out_noise) + + chunk[:attack] = np.multiply(chunk[:attack], fade_in) + chunk[-decay:] = np.multiply(chunk[-decay:], fade_out) + + all_tones.append(chunk) + + chunk = sum(all_tones) + # + # plt.plot(chunk) + # plt.show() + + stream.write(chunk.astype(np.float32).tostring()) diff --git a/audio/Oscillators/sine_osc_patrick.py b/audio/Oscillators/sine_osc_patrick.py new file mode 100644 index 0000000..4331864 --- /dev/null +++ b/audio/Oscillators/sine_osc_patrick.py @@ -0,0 +1,68 @@ +from __future__ import division +from math import pi +import numpy as np +from Filters.butter_bandpass_filter import butter_bandpass_filter +import random +import matplotlib.pyplot as plt + + +class SineOscPatrick: + def __init__(self): + self.sample_rate = 44100 + + def wave(self, frequency, length, rate): + """produces sine across np array""" + + length = int(length * rate) + factor = float(frequency) * (pi * 2) / rate + waveform = np.sin(np.arange(length) * factor) + + rounded_waveform = np.round(waveform, 0) + + waveform2 = np.power(waveform, 3) + waveform3 = np.power(rounded_waveform, 4) / 4 + + pre_filtered = np.add(waveform, waveform3) + pre_filtered = np.add(pre_filtered, waveform2) + + return pre_filtered + + def play_frequencies(self, stream, length, volume, attack, decay, *freqs): + """Plays a group of frequencies""" + volume *= .25 + all_tones = [] + + for freq in freqs: + i = freq + 100 + if freq > 1000: + volume *= .3 + chunks = [self.wave(freq, length, self.sample_rate)] + + if freq < 100: + volume *= 1.5 + + chunk = np.concatenate(chunks) * volume + + fade_in = np.arange(0., 1., 1./attack) + fade_out = np.arange(1., 0., -1./decay) + + first_noise = np.random.normal(0, random.choice([.04, .05, .04]), len(chunk[:attack])) * 1 + second_noise = np.random.normal(0, random.choice([.04, .07, .08, .08]), len(chunk[-decay:])) * 1 + + in_noise = np.multiply(first_noise, np.flipud(fade_in)) + out_noise = np.multiply(second_noise, np.flipud(fade_out)) + + chunk[:attack] = np.add(chunk[:attack], in_noise) + chunk[-decay:] = np.add(chunk[-decay:], out_noise) + + chunk[:attack] = np.multiply(chunk[:attack], fade_in) + chunk[-decay:] = np.multiply(chunk[-decay:], fade_out) + + all_tones.append(chunk) + + chunk = sum(all_tones) + # + # plt.plot(chunk) + # plt.show() + + stream.write(chunk.astype(np.float32).tostring()) diff --git a/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__1.wav b/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__1.wav new file mode 100644 index 0000000..fb95189 Binary files /dev/null and b/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__1.wav differ diff --git a/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__2.wav b/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__2.wav new file mode 100644 index 0000000..2d7cde9 Binary files /dev/null and b/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__2.wav differ diff --git a/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__3.wav b/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__3.wav new file mode 100644 index 0000000..0ab9ec9 Binary files /dev/null and b/audio/Training/training_data/A3/name=A3__num=12__batch=y2017m04d13H21M36S37__3.wav differ diff --git a/audio/npm-debug.log b/audio/npm-debug.log new file mode 100644 index 0000000..12d6ad9 --- /dev/null +++ b/audio/npm-debug.log @@ -0,0 +1,22 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/local/Cellar/node/7.4.0/bin/node', +1 verbose cli '/usr/local/bin/npm', +1 verbose cli 'test' ] +2 info using npm@4.0.5 +3 info using node@v7.4.0 +4 verbose config Skipping project config: /Users/dannymeyer/.npmrc. (matches userconfig) +5 verbose stack Error: ENOENT: no such file or directory, open '/Users/dannymeyer/package.json' +6 verbose cwd /Users/dannymeyer/Documents/projects/audio_visual/audio +7 error Darwin 16.5.0 +8 error argv "/usr/local/Cellar/node/7.4.0/bin/node" "/usr/local/bin/npm" "test" +9 error node v7.4.0 +10 error npm v4.0.5 +11 error path /Users/dannymeyer/package.json +12 error code ENOENT +13 error errno -2 +14 error syscall open +15 error enoent ENOENT: no such file or directory, open '/Users/dannymeyer/package.json' +16 error enoent ENOENT: no such file or directory, open '/Users/dannymeyer/package.json' +16 error enoent This is most likely not a problem with npm itself +16 error enoent and is related to npm not being able to find a file. +17 verbose exit [ -2, true ] diff --git a/audio/show.py b/audio/show.py new file mode 100644 index 0000000..68c77de --- /dev/null +++ b/audio/show.py @@ -0,0 +1,26 @@ +import random +import pyaudio +from Oscillators.sine_osc import SineOsc + +sine_osc = SineOsc() + +p = pyaudio.PyAudio() +stream = p.open(format=pyaudio.paFloat32, + channels=1, + rate=44100, + output=1, + ) + + +def pretty(freq): + sine_osc.play_frequencies(stream, 3, .5, 200, 200, + freq, + # freq + 3.2, + # freq + 2, + freq * 3/2, + freq * 9/8, + freq * 11/8, + ) + + +pretty(400) diff --git a/visual/glfw b/visual/glfw new file mode 160000 index 0000000..a368d89 --- /dev/null +++ b/visual/glfw @@ -0,0 +1 @@ +Subproject commit a368d89c947db11afb97bc4788022929fcd71493