Okay, this is a weird one.
I wrote a method (as part of YummyFillings.rb) for tremolo – manipulating the volume periodically.
When applied to a single note, it works as expected, but when applied to a chord, it seems to be increasing the volume. I hypothesize that it’s cloning the note, leaving the original note still sustaining while playing the same note at the newly manipulated amp value.
Here’s the method (part of YummyFillings.rb):
define :tremolo do |handle, amp=1, depth=1, rate=sixteenth, duration=whole, **kwargs|
eval overridekwargs(kwargs, method(__method__).parameters)
cleanargs = stripparams kwargs, method(__method__).parameters
debugprint "top of tremolo"
debugprint "handle: ", handle
debugprint "amp: ", amp
debugprint "depth: ", depth
debugprint "rate: ", rate
debugprint "duration: ", duration
halfrate = rate / 2.0
elapsedtime = 0
debugprint "about to thread"
direction = 1
in_thread do
while elapsedtime < duration do
debugprint "elapsedtime: ", elapsedtime
if handle.is_a? SonicPi::ChordGroup
debugprint "got a chord group"
pitch = pitch.to_a
debugprint "pitch: ", pitch
handle.sub_nodes.each do |subhandle|
debugprint "subhandle: ", subhandle
control subhandle, amp: (amp + (depth * direction)), amp_slide: halfrate
end #each subhandle
else
debugprint "got a single note"
control handle, amp: (amp + (depth * direction)), amp_slide: halfrate
end #if chordgroup or single note
sleep halfrate
direction *= -1
elapsedtime += halfrate
end #while elapsedtime < duration
debugprint "bottom of time loop"
if handle.is_a? SonicPi::ChordGroup
debugprint "got a chord group"
pitch = pitch.to_a
debugprint "pitch: ", pitch
handle.sub_nodes.each do |subhandle|
debugprint "subhandle: ", subhandle
control subhandle, amp: amp, amp_slide: halfrate
end #each subhandle
else
debugprint "got a single note"
control handle, amp: amp, amp_slide: halfrate
end #if chordgroup or single note
stop
end #in_thread
handle #return value
end #define tremolo
…and here’s the code showing the problem with chords:
eval_file "e:/yummy/yummyfillings.rb"
bar = 16.0
whole = 4.0
half =2.0
quarter =1.0
eighth =0.5
sixteenth =0.25
dotted =1.5
triplet =2.0 / 3
halftone = 1
second = 2
wholetone = 2
min3 = 3
maj3 = 4
fourth = 5
tritone = 6
fifth = 7
min6 = 8
maj6 = 9
min7 = 10
maj7 = 11
octave = 12
play :c4
sleep quarter
tremolo (play :c4)
sleep quarter
play (chord :c4, "m7")
sleep quarter
tremolo (play (chord :c4, "m7"))
With the single note, the volumes sound in similar ballpark – the tremolo revolves around the 1 amp level range. But with the chord, it’s twice as loud.
Any idea what’s going on here?
Thanks!