Last active
August 29, 2015 14:22
-
-
Save somebox/2f1a787e45ef9decb918 to your computer and use it in GitHub Desktop.
music dsl in ruby idea
This file contains hidden or 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
# song definition | |
tempo 120 | |
# bassline | |
instrument :bass, channel: 2 do | |
preset 'bass/fender_jazz_clean' | |
end | |
pattern :funky do | |
note_filter "a b- c e f g a-" do | |
pattern_generator(16, swing: 30) | |
end | |
end | |
pattern :drone do | |
notes "a" x 12 + "bded" | |
end | |
sequence :bassline do | |
pattern: :drone | |
end | |
# drums | |
pattern :snap do | |
hihat1 = ".--. ..-. ..-. ..--" | |
snare = "...x ...x ...x ..xx" | |
bass_drum = "^.^. ^.^. .^.^ ^^^*" | |
cymbal1 = ".... .... .... ...x" | |
cymbal2 = cymbal1.gsub(/x/, '-') | |
play_together(length: 4.bars, note: :quarter) do | |
play hihat, note: 'd-' | |
play snare, note: 'd' | |
play bass_drum, note: 'c' | |
play (rand(1) == 0 ? cymbal1 : cymbal2), note: 'b-' | |
end | |
end | |
instrument :drums do | |
preset 'drums/brooklyn_set' | |
pattern :snap | |
end | |
sequence :funky_part do | |
play_together repeat: 3.times do | |
play :bassline | |
play :drums | |
end | |
play :bassline, pattern: :funky | |
end | |
sequence :break do | |
play sample: 'funky_break', playback: 2.times.faster, length: 4.bars | |
end | |
section :intro do | |
fade controller: :velocity, range: 60..120, rise: :fast, length: 2.bars do | |
play sequence: :bassline | |
end | |
end | |
section :exit do | |
play sample: 'door_closing' | |
end | |
song :get_down_on_it do | |
play :intro | |
play :funky_part | |
play :break | |
play :funky_part | |
play_together do | |
play :break | |
play :intro, repeat: 2.times | |
play :exit | |
end | |
# my stuff | |
def pattern_generator(notes) | |
(1..notes).to_a.each do | |
note rand(12) + 20 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment