Skip to content

Instantly share code, notes, and snippets.

@xavriley
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavriley/b4c989f728c97cbd9d36 to your computer and use it in GitHub Desktop.
Save xavriley/b4c989f728c97cbd9d36 to your computer and use it in GitHub Desktop.
Prototype drop-ii harmoniser in Sonic Pi
c_bebop = [60,62,64,65,67,68,69,71]
current_scale = (c_bebop.map {|x| x - 12 } + \
c_bebop + \
c_bebop.map {|x| x + 12 } + \
c_bebop.map {|x| x + 24 }).flatten
def chord_tones(n, scale)
return n if n.nil?
idx = scale.to_a.index(note(n).to_i)
if idx.even?
scale.to_a.select.with_index {|x, sidx| sidx >= idx && sidx.even? }.take(4)
else
scale.to_a.select.with_index {|x, sidx| sidx >= idx && sidx.odd? }.take(4)
end
end
def close_harmony(n, scale)
return n if n.nil?
chord_tones(n, scale)
end
def drop_two(n, scale)
return n if n.nil?
chrd = chord_tones(n, scale)
[chrd[2] - 12, chrd[0], chrd[1], chrd[3]]
end
def drop_three(n, scale)
return n if n.nil?
chrd = chord_tones(n, scale)
[chrd[1] - 12, chrd[0], chrd[2], chrd[3]]
end
in_the_mood = [:c, :e, :g, :c5, nil, :c5, nil, :c5,
nil, :c5, nil, :c5, :b, :c5, :g, :e]
use_bpm 130
use_synth_defaults release: 0.4
use_synth :tri
play_pattern_timed in_the_mood.map {|x| drop_two(x, current_scale) }, [0.53, 0.47]
# Some experiments in making triadic harmony
#
#def interval(n, interval, scale)
# idx = scale.to_a.index(note(n).to_i)
# scale.to_a.ring[idx + (interval - 1)]
#end
#
#def harm(n, scale)
# chrd = []
# chrd << note(n)
# chrd << interval(chrd.last, 2, scale)
# chrd << interval(chrd.last, 3, scale)
# chrd << interval(chrd.last, 4, scale)
# chrd
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment