From f3b94b80b0921679513550bb89e30ea6566ceaec Mon Sep 17 00:00:00 2001 From: MJ McMillen <16mmcmillen.stem@gmail.com> Date: Sun, 23 Apr 2017 20:48:33 -0400 Subject: [PATCH] Finnally remembering to push all my toolboxes.... This toolbox was really fun! --- blues_solo.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/blues_solo.py b/blues_solo.py index 0408e06..ca3564f 100644 --- a/blues_solo.py +++ b/blues_solo.py @@ -11,6 +11,10 @@ SAMPLE_FILE = os.path.join(SAMPLES_DIR, "bass_D2.wav") SAMPLE_NOTE = D2 # the sample file plays at this pitch +BACKING_TRACK = os.path.join(SAMPLES_DIR, "backing.wav") +sample(BACKING_TRACK, amp=1) +sleep(2.25) # delay the solo to match up with backing track + def play_note(note, beats=1, bpm=60, amp=1): @@ -39,4 +43,18 @@ def stop(): blues_scale = [40, 43, 45, 46, 47, 50, 52, 55, 57, 58, 59, 62, 64, 67, 69, 70, 71, 74, 76] beats_per_minute = 45 # Let's make a slow blues solo -play_note(blues_scale[0], beats=1, bpm=beats_per_minute) +#play_note(blues_scale[0], beats=1, bpm=beats_per_minute) +curr_note = 0 +play_note(blues_scale[curr_note], 1, beats_per_minute) +licks = [[(1, 0.5*1.1), (1, 0.5*0.9), (1, 0.5*1.1), (1, 0.5*0.9)],[(1, 0.5*1.1), (1, 0.5*0.9), (-1, 0.5*1.1), (-1, 0.5*0.9)],[(1, 0.25*1.1), (-1, 0.5*0.9), + (2, 0.75*1.1), (1, 0.5*0.9)]] +for _ in range(6): + lick = licks[random.choice([0,1,2])] + for note in lick: + if curr_note +note[0]<0: + curr_note = curr_note+1 + elif curr_note + note[0] > len(blues_scale)-1: + curr_note+= curr_note-note[0] + else: + curr_note += note[0] + play_note(blues_scale[curr_note], note[1], beats_per_minute)