Hi there,
Questions about parameters, question in code.
# so let met introduce you raymond my new synth
# first parameter : the instrument
instruments = ['piano', 'tri', 'pluck']
define :raymond do | numInstrument=0, a=0, d=0.5, s=0.5, r=0.5, amp=1 |
use_synth instruments[numInstrument]
use_synth_defaults attack: a, decay: d, sustain: s, release: r, amp: amp
end
raymond(0) # instrument the first one
play :c4
sleep 1
raymond() # instrument the first one cause numInstrument is set to 0 in define
play :c4
sleep 1
raymond(1) # instrument the second one
raymond 1 # we can write as this too
raymond 0 , '' , '', '', 0.125, 2
play :c4
sleep 1
raymond(0,0.125) # instrument 0, attack: 0.125, the others parameters to the default values
play :c4
sleep 1
raymond 0, 0.125, 0.25, 0.125, 1, 2 # instrument 0, attack: 0.125, decay: 0.25, sustain: 0.125, release: 1, amp:2
play :c4
# ok now let say i want to set only the amp parameter and for the other values the default values
# what's the good syntax if it's possible ?
raymond(amp=4) # nope :-(
play :c4
# what about setting the two first arguments, not the third, and then the latest ?
raymond 0, , , 0.125, 0.5, 1 # instrument 0, attack: 0.125, decay: 0.25, sustain: 0.125, release: 1, amp:2
play :c4
Thanks for your help.