diff --git a/blues_solo.py b/blues_solo.py index 45791ad..ea324b4 100644 --- a/blues_solo.py +++ b/blues_solo.py @@ -2,7 +2,7 @@ from Nsound import * import numpy as np -from random import choice +import random def add_note(out, instr, key_num, duration, bpm, volume): """ Adds a note from the given instrument to the specified stream @@ -31,6 +31,36 @@ def add_note(out, instr, key_num, duration, bpm, volume): blues_scale = [25, 28, 30, 31, 32, 35, 37, 40, 42, 43, 44, 47, 49, 52, 54, 55, 56, 59, 61] beats_per_minute = 45 # Let's make a slow blues solo -add_note(solo, bass, blues_scale[0], 1.0, beats_per_minute, 1.0) +# add_note(solo, bass, blues_scale[0], 1.0, beats_per_minute, 1.0) -solo >> "blues_solo.wav" \ No newline at end of file +# solo >> "blues_solo.wav" + +curr_note = 0 + +volume = 1.0 +volume_factor = [.9, 1.7] +add_note(solo, bass, blues_scale[curr_note], 1.0, beats_per_minute, volume) + +licks = [ [ [1,0.5*1.1], [-1,0.5], [-1, 0.5*1.1], [2, 0.5], [1,0.5*.9], [-2, .5*.9], [2,.5],[3,1],[-2, .5] ] ] +for i in range(4): + lick = random.choice(licks) + for note in lick: + curr_note += note[0] + if curr_note < 0: + curr_note = 0 + if curr_note > len(blues_scale) - 1: + curr_note = len(blues_scale) - 1 + add_note(solo, bass, blues_scale[curr_note], note[1], beats_per_minute, volume * random.choice(volume_factor)) + +backing_track = AudioStream(sampling_rate, 1) +Wavefile.read('backing.wav', backing_track) + +m = Mixer() + +solo *= 0.4 # adjust relative volumes to taste +backing_track *= 2.0 + +m.add(2.25, 0, solo) # delay the solo to match up with backing track +m.add(0, 0, backing_track) + +m.getStream(500.0) >> "slow_blues.wav" \ No newline at end of file