Created
June 13, 2019 18:09
-
-
Save datramt/22e5af2ddf4c872605d4a625690b64ec to your computer and use it in GitHub Desktop.
strategies for generating melodies and bass lines in sonic pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# STRATEGIES FOR GENERATING MELODIES & BASS LINES | |
# scale pattern | |
##| my_mel = (scale :e, :minor) # returns a ring | |
# adding rings together will "concatenate" the lists | |
##| my_mel = (scale :e, :minor) + (ring :r, :r, :r, :r, :r, :r, :r, :r) | |
# call the "shuffle" method to scramble the scale and mix in rests | |
##| my_mel = ((scale :e, :minor) + (ring :r, :r, :r, :r, :r, :r, :r, :r)).shuffle | |
# use knit as short-hand to generate a ring of 8 rests | |
##| my_mel = (knit :r, 8) | |
# shuffle scale with rests as before, but with short-hand "knit" | |
##| my_mel = ((scale :e, :minor) + (knit :r, 8)).shuffle | |
# if you want to force a max of, say, 8 notes | |
##| my_mel = ((scale :e, :minor) + (knit :r, 8)).shuffle.take(8) | |
# make :e more likely to generate by concatenating 8 :e's | |
##| my_mel = ((scale :e, :minor) + (knit :e, 8) + (knit :r, 8)).shuffle.take(8) | |
# get it perfect by "auditioning seeds" | |
use_random_seed 6 | |
my_mel = ((scale :e, :minor) + (knit :e, 8) + (knit :r, 8)).shuffle.take(8) | |
puts my_mel | |
use_synth :pluck | |
live_loop :mel do | |
play my_mel.tick | |
sleep 0.25 | |
end | |
# when generating a bass line, consider using "chords" rather than "scales" | |
# try to match bass note (in this case, :e) | |
# try to match quality (:minor is compatible with :m9) | |
# consider the length of the resulting chord ring when knitting other values | |
use_random_seed 9 | |
puts my_bas = ((chord :e2, :m9) + (knit :r, 8)).shuffle.take(8) | |
use_synth :pluck | |
live_loop :bas do | |
play my_bas.tick | |
sleep 0.25 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment