I am having quite a hard time improvising melodies with Sonic Pi.
A popular approach to improvisation (in jazz music) is to build “phrases” over chord progressions, using only the notes contained in the scale of every chord the harmony plays.
I am trying to code something like this, but the result turns out to be quite disappointing:
use_bpm 120 note_duration = ring( 2.0, # double 1.0, # whole 0.5, # half 0.75 # dot half ) scl = :major chord_progression = ring(:ii, :v, :i, :i) define :play_note do |note| play note \ ,release: note_duration.choose() \ ,attack: [0,0,0,note_duration.tick/4].choose() \ ,decay: [0,0,0,note_duration.tick/4].choose() \ ,sustain: [0,0,0,note_duration.tick/4].choose() \ ,amp: [1.0,0.75,0.25].choose() end live_loop :melody do chord_progression.each do |crd| phrase_finished = false 8.times do print "=== ", crd, " ===" if one_in(10) and not phrase_finished then phrase_finished = true else if one_in(6) then # Silence sleep [0.125,0.5,0.250].choose() else play_note chord_degree(crd, :C4, scl).choose() end end sleep 1 end end end
Even though the code plays the right notes for every chord in the ii-V-I progression, it seems that I am missing something for the most important part: the rythm
Suggestion and ideas will be greatly appreciated. Cheers!