Created
August 16, 2015 14:23
-
-
Save mbutz/93fb8c79bccd4355b8f4 to your computer and use it in GitHub Desktop.
Base of AFX 1.7 - helper functions, patterns and song modules
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
# AFX 1.7, prepare the tune | |
use_debug false | |
set_volume! 1 | |
use_bpm 128 | |
load_samples [:loop_compus, :elec_wood, :drum_bass_hard, :drum_snare_hard, :drum_snare_hard, :drum_cymbal_closed, :elec_snare, :drum_tom_hi_soft] | |
# Helper Functions | |
# Return note duration based on the defined rythmic pattern | |
define :get_dur do |ptn| | |
if ptn.count == 1 | |
d = 4 | |
elsif ptn.count == 2 | |
d = 2 | |
elsif ptn.count == 4 | |
d = 1 | |
elsif ptn.count == 8 | |
d = 0.5 | |
elsif ptn.count == 16 | |
d = 0.25 | |
elsif ptn.count == 32 | |
d = 0.125 | |
else | |
puts "NOTE: No idea what rythmic pattern you mean!" | |
end | |
return d | |
end | |
define :play_sample do |spec, ptn| | |
# take orders, what and how to play | |
# work out time measure | |
d = get_dur ptn | |
ptn.each do |i| | |
if i != 0 | |
sample spec[0], amp: spec[1], rate: spec[2], pan: spec[3], start: spec[4], finish: spec[5] | |
end | |
sleep d | |
end | |
end | |
define :play_synth do |notes| | |
t = get_dur notes | |
notes.each do |n| | |
if n[0] == :to | |
control (play n[4], note_slide: n[1], sustain: n[2], release: n[3]), amp: 3, note: n[5] | |
puts "Glissando: #{n}" | |
elsif n != :- | |
play n | |
end | |
sleep t | |
end | |
end | |
# rhythmic patterns (ptn) | |
# 1 e + e 2 e + e 3 e + e 4 e + e | |
beep_ptn = [1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0] | |
cbsa_on_ptn_a = [1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0] | |
cbsa_of_ptn_a = [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1] | |
cbsa_on_ptn_b = [1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0] | |
cbsa_of_ptn_b = [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1] | |
beat_on_ptn = [1,0,1,0,1,0,1,0] | |
beat_of_ptn = [0,1,0,1,0,1,0,1] | |
tick_ptn = [1,1,0,0,0,1,0,0,1,1,0,0,0,1,0,0] | |
cong_low_ptn = [1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0] | |
cong_mdm_ptn = [0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0] | |
cong_hih_ptn = [0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0] | |
bass_on_ptn_1 = [1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0] | |
bass_of_ptn_1 = [0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0] | |
bass_ptn_2a = [1,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0] | |
bass_ptn_2b = [1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0] | |
bass_ptn_2_br = [1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0] | |
snre_on_ptn_1 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0] | |
snre_of_ptn_1 = [0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0] | |
snre_ptn_2 = [0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0] | |
snre_hr_ptn_a = [0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0] | |
snre_hr_ptn_b = [0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0] | |
hiht_on_ptn = [1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0] | |
hiht_of_ptn = [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1] | |
hiht_lo_ptn = [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0] | |
hiht_hi_ptn = [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0] | |
hiht_on_ptn_br = [1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0] | |
hiht_of_ptn_br = [0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0] | |
hiht_lo_ptn_br = [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0] | |
hiht_hi_ptn_br = [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0] | |
cong_low_ptn = [1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0] | |
cong_mdm_ptn = [0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0] | |
cong_hih_ptn = [0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0] | |
tick_ptn = [0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0] | |
# lines for synths | |
bodn_fg_ptn = [[:e4,:a3],:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-] | |
bodn_bg_ptn = [[:e3,:a2],:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-] | |
bodn_pk_ptn = [[:e5,:a4],:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-] | |
bnce_ptn_b1 = [[:e3,:a4],[:e3,:a4],:-,:-, | |
:-,:-,[:e3,:a4],:-, | |
:-,[:e3,:a4],:-,:-, | |
[:e3,:a4],:-,[:e3,:a4],:-] | |
bnce_ptn_b2 = [[:a4,:d5],[:a4,:d5],:-,:-, | |
:-,:-,[:a4,:d5],:-, | |
:-,[:a4,:d5],:-,:-, | |
[:a4,:d5],:-,[:a4,:d5],:-] | |
bnce_ptn_b3 = [[:g4,:b4],[:g4,:b4],:-,:-, | |
:-,:-,[:g4,:b4],:-, | |
:-,[:g4,:b4],:-,:-, | |
[:g4,:b4],:-,[:g4,:b4],:-] | |
bnce_ptn_b4 = [[:d4,:fs4],:-,[:d4,:fs4],:-, | |
:-,:-,:-,[:d4,:fs4], | |
:-,:-,[:d4,:fs4],:-, | |
:-,[:d4,:fs4],:-,[:d4,:fs4]] | |
frog_ptn = [:-,:-,:-,:-,:-,:g1,:-,:-,:-,:-,:-,:-,:-,:-,:-,:-] | |
flute_ptn_a = [:-,:-,:-,:-,[:to,1,0.5,0.5,:g5,:fs5],:-,[:to,1,1,1,:f5,:e5],:-] | |
flute_ptn_b = [:-,:-,:-,:-,[:to,1,0.5,0.5,:g4,:fs4],:-,:-,:-] | |
flute_ptn_v = [[:-,:-,:-,:-,:-,:-,:-,:-], | |
[:-,:-,:-,:-,:-,:-,:-,:-], | |
[:-,:-,:-,:-,:-,:-,:-,:-], | |
[:-,:-,:-,:-,:-,:-,:-,:-]] | |
flute_ptn_v = [[:-,[:to,1,0.5,0.5,:g5,:fs5],:-,:-,:-,:-,:-,:-], | |
[:-,:-,:-,[:to,1,0.5,0.5,:b4,:a4],:-,:-,:-,:-], | |
[:-,[:to,1,0.5,0.5,:e5,:fs5],:-,:-,[:to,1,0.5,0.5,:a5,:b5],:-,:-,:-], | |
[:-,:-,:-,:-,:-,:-,:-,[:to,1,0.5,0.5,:g4,:e4]], | |
[:-,:-,:-,:-,[:to,1,0.5,0.5,:g5,:fs5],:-,[:to,1,1,1,:f5,:e5],:-], | |
[:-,:-,:-,:-,[:to,1,0.5,0.5,:g4,:fs4],:-,:-,:-]] | |
tune_ptn_b1 = [:a4,:-,:-,:-, | |
:b4,:-,:d5,:-, | |
:e5,:-,:-,:-, | |
:-,:-,:a4,:-] | |
tune_ptn_b2 = [:b4,:a4,:-,:-, | |
:b4,:-,:d5,:-, | |
:-,:e5,:-,:-, | |
:a4,:-,:-,:-] | |
tune_ptn_b3 = [:g4,:-,:-,:-, | |
:a4,:-,:-,:-, | |
:b4,:-,:-,:-, | |
:-,:-,:-,:-] | |
tune_ptn_b4 = [:a4,:-,:g4,:-, | |
:-,:-,:-,:a4, | |
:-,:-,:b4,:-, | |
:a4,:-,:-,:-] | |
# Song Modules | |
define :mod_shaker do | |
in_thread do | |
2.times do | |
play_sample [:loop_compus, 5, 1, 0, 0.17, 0.2], cbsa_on_ptn_a | |
play_sample [:loop_compus, 5, 1, 0, 0.17, 0.2], cbsa_on_ptn_b | |
end | |
end | |
in_thread do | |
2.times do | |
play_sample [:loop_compus, 3.5, 0.95, 0, 0.17, 0.2], cbsa_of_ptn_a | |
play_sample [:loop_compus, 3.5, 0.95, 0, 0.17, 0.2], cbsa_of_ptn_b | |
end | |
end | |
in_thread do | |
2.times do | |
play_sample [:loop_compus, 8, 1, 0, 0.19, 0.2], tick_ptn | |
play_sample [:loop_compus, 8, 1, 0, 0.19, 0.2], tick_ptn | |
end | |
end | |
in_thread do | |
2.times do | |
play_sample [:elec_wood, 0.7, 9, 0, 0, 1], beat_on_ptn | |
play_sample [:elec_wood, 0.7, 9, 0, 0, 1], beat_on_ptn | |
end | |
end | |
in_thread do | |
2.times do | |
play_sample [:elec_wood, 0.5, 7, 0, 0, 1], beat_of_ptn | |
play_sample [:elec_wood, 0.5, 7, 0, 0, 1], beat_of_ptn | |
end | |
end | |
end | |
define :mod_bordun do | |
in_thread do | |
use_synth :tri | |
use_synth_defaults amp: 0.5, cutoff: 0, attack: 0.8, sustain: 3, release: 4, pan: 0.2, depth: 20 | |
2.times do | |
with_fx :flanger, phase: 10, wave: 3 do | |
play_synth bodn_fg_ptn | |
end | |
sleep 4 | |
end | |
end | |
in_thread do | |
use_synth :tri | |
use_synth_defaults amp: 0.3, attack: 3, sustain: 2, release: 3, pan: -0.2, depth: 10 | |
2.times do | |
with_fx :flanger, phase: 10, wave: 3 do | |
play_synth bodn_bg_ptn | |
end | |
sleep 4 | |
end | |
end | |
in_thread do | |
use_synth :tri | |
use_synth_defaults amp: 0.4, cutoff: 0, attack: 0.3, sustain: 3, release: 5, pan: 0.2, depth: 0 | |
2.times do | |
with_fx :flanger, phase: 10, wave: 3 do | |
play_synth bodn_pk_ptn | |
end | |
sleep 4 | |
end | |
end | |
end | |
define :mod_frog do | |
use_synth :tb303 | |
use_synth_defaults amp: 5, attack: 0.3, sustain: 0.4, release: 0.2, pan: rrand(-0.4, 0.1), res: 0.1 | |
in_thread do | |
with_fx :reverb, room: 0.4 do | |
4.times do | |
play_synth frog_ptn | |
end | |
end | |
end | |
end | |
define :mod_drums_1 do | |
in_thread do | |
4.times do | |
play_sample [:drum_bass_hard, 3, 0.7, -0.2, 0, 1], bass_on_ptn_1 | |
end | |
end | |
in_thread do | |
4.times do | |
play_sample [:drum_bass_hard, 1.5, 0.7, -0.2, 0, 1], bass_of_ptn_1 | |
end | |
end | |
in_thread do | |
4.times do | |
play_sample [:drum_snare_hard, 2, 1.275, -0.1, 0, 1], snre_on_ptn_1 | |
end | |
end | |
in_thread do | |
4.times do | |
play_sample [:drum_snare_hard, 2, 1.3, -0.1, 0, 1], snre_of_ptn_1 | |
end | |
end | |
end | |
define :mod_drums_2 do | |
in_thread do | |
play_sample [:drum_bass_hard, 3, 0.7, -0.2, 0, 1], bass_ptn_2a | |
play_sample [:drum_bass_hard, 3, 0.7, -0.2, 0, 1], bass_ptn_2b | |
play_sample [:drum_bass_hard, 3, 0.7, -0.2, 0, 1], bass_ptn_2a | |
play_sample [:drum_bass_hard, 3, 0.7, -0.2, 0, 1], bass_ptn_2b | |
end | |
in_thread do | |
play_sample [:drum_snare_hard, 2, 1.275, -0.1, 0, 1], snre_ptn_2 | |
play_sample [:drum_snare_hard, 2, 1.275, -0.1, 0, 1], snre_ptn_2 | |
play_sample [:drum_snare_hard, 2, 1.275, -0.1, 0, 1], snre_ptn_2 | |
play_sample [:drum_snare_hard, 2, 1.275, -0.1, 0, 1], snre_ptn_2 | |
end | |
end | |
define :mod_hiht do | |
in_thread do | |
4.times do | |
play_sample [:drum_cymbal_closed, 2, 1, -0.5, 0, 0.4, 1], hiht_on_ptn | |
end | |
end | |
in_thread do | |
4.times do | |
play_sample [:drum_cymbal_closed, 2, 1.3, -0.5, 0, 0.3], hiht_of_ptn | |
end | |
end | |
in_thread do | |
4.times do | |
play_sample [:drum_cymbal_closed, 3, 1, -0.4, 0.0, 0.6], hiht_lo_ptn | |
end | |
end | |
in_thread do | |
4.times do | |
play_sample [:drum_cymbal_closed, 3, 1, -0.4, 0.0, 0.6], hiht_hi_ptn | |
end | |
end | |
end | |
define :mod_snre_hr do | |
in_thread do | |
play_sample [:elec_snare, 0.7, 0.5, -0.1, 0, 0.4], snre_hr_ptn_a | |
play_sample [:elec_snare, 0.7, 0.5, -0.1, 0, 0.4], snre_hr_ptn_a | |
play_sample [:elec_snare, 0.7, 0.5, -0.1, 0, 0.4], snre_hr_ptn_a | |
play_sample [:elec_snare, 0.7, 0.5, -0.1, 0, 0.4], snre_hr_ptn_a | |
end | |
in_thread do | |
play_sample [:elec_snare, 0.7, 0.5, -0.1, 0, 0.4], snre_hr_ptn_b | |
play_sample [:elec_snare, 0.7, 0.5, -0.1, 0, 0.4], snre_hr_ptn_b | |
play_sample [:elec_snare, 0.7, 0.5, -0.1, 0, 0.4], snre_hr_ptn_b | |
play_sample [:elec_snare, 0.7, 0.5, -0.1, 0, 0.4], snre_hr_ptn_b | |
end | |
end | |
define :mod_congas do | |
in_thread do | |
4.times do | |
play_sample [:drum_tom_hi_soft, 2, 1.05, -0.8, 0.1, 1], cong_low_ptn | |
end | |
end | |
in_thread do | |
4.times do | |
play_sample [:drum_tom_hi_soft, 3, 1.17, -0.2, 0.1, 1], cong_mdm_ptn | |
end | |
end | |
in_thread do | |
4.times do | |
play_sample [:drum_tom_hi_soft, 3, 1.23, 0.6, 0.1, 1], cong_hih_ptn | |
end | |
end | |
end | |
define :mod_flute do | |
use_synth :fm | |
use_synth_defaults amp: 1, attack: 0.3, sustain: 0.2, release: 0.2, pan: 1 | |
in_thread do | |
with_fx :reverb, room: 0.9 do | |
play_synth flute_ptn_a | |
end | |
end | |
in_thread do | |
sleep 8 | |
with_fx :reverb, room: 0.9 do | |
play_synth flute_ptn_b | |
end | |
end | |
end | |
define :mod_flute_rand do | |
use_synth :fm | |
use_synth_defaults amp: 1, attack: 0.3, sustain: 0.2, release: 0.2, pan: 1 | |
in_thread do | |
with_fx :reverb, room: 0.9 do | |
use_random_seed rand_i(11) | |
play_synth choose(flute_ptn_v) | |
end | |
end | |
in_thread do | |
sleep 4 | |
with_fx :reverb, room: 0.9 do | |
use_random_seed rand_i(25) | |
play_synth choose(flute_ptn_v) | |
end | |
end | |
in_thread do | |
sleep 8 | |
with_fx :reverb, room: 0.9 do | |
use_random_seed rand_i(37) | |
play_synth choose(flute_ptn_v) | |
end | |
end | |
in_thread do | |
sleep 12 | |
with_fx :reverb, room: 0.9 do | |
use_random_seed rand_i(59) | |
play_synth choose(flute_ptn_v) | |
end | |
end | |
end | |
define :mod_bouncer do | |
use_synth :fm | |
use_synth_defaults amp: 10, attack: 0, sustain: 0.2, release: 0.1, pan: 0.2, depth: 0.5 | |
in_thread do | |
with_fx :reverb, room: 0.9 do | |
play_synth bnce_ptn_b1 | |
play_synth bnce_ptn_b2 | |
play_synth bnce_ptn_b3 | |
play_synth bnce_ptn_b4 | |
end | |
end | |
end | |
define :mod_bouncer_init do | |
use_synth :cnoise | |
use_synth_defaults amp: 0.6, attack: 0.1, sustain: 0.2, release: 1, pan: 0.2 | |
in_thread do | |
with_fx :reverb, room: 0.9 do | |
play_synth bnce_ptn_b1 | |
play_synth bnce_ptn_b2 | |
play_synth bnce_ptn_b3 | |
play_synth bnce_ptn_b4 | |
end | |
end | |
end | |
define :mod_tune do | |
use_synth :saw | |
use_synth_defaults amp: 4, attack: 0, sustain: 0.1, release: 0.2, pan: -0.3 | |
in_thread do | |
with_fx :reverb, room: 0.5 do | |
play_synth tune_ptn_b1 | |
play_synth tune_ptn_b2 | |
play_synth tune_ptn_b3 | |
play_synth tune_ptn_b4 | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment