Sure. Here’s the code. The debugprint is a souped-up puts command.
define :passkwargsthrough do |cmd, kwargs|
if kwargs == nil
debugprint "no args, clean call"
else
debugprint "got kwargs, cooking cmd"
comma = ","
if !cmd.include? " "
debugprint "no space, zapping first comma"
comma = ""
end
debugprint "comma: ", comma
kwargs.each do |key, value|
debugprint "key: ", key
debugprint "value: ", value
if ringorlist value
debugprint "value is a ring or list"
value = value.to_a
debugprint "value: ", value
end #if ring or list
cmd += comma + key.to_s + ": " + value.to_s
comma = ","
end #each key value pair
debugprint "cmd: ", cmd
cmd #return value
end
end
define :strum do |thesenotes,strumspeed=0.05,totaltime, **synthdefaults|
debugprint "top of strum"
thesenotes = cleanchordorscale thesenotes
debugprint "clean version of thesenotes: ", thesenotes
lastnotelength=totaltime - (strumspeed * (thesenotes.length - 1))
thesedelays= knit(strumspeed, thesenotes.length - 1)
(thesedelays = thesedelays.to_a) << lastnotelength
debugprint "final version of thesedelays: ", thesedelays
cmd = "arpeggiate " + thesenotes.to_s + ", " + thesedelays.to_s
cmd = passkwargsthrough cmd, synthdefaults
debugprint "cmd: ", cmd
eval cmd
end
use_synth :piano
strum (chord :c4, "m7"), 0.05, 2, amp: [0.1, 0.3, 0.5, 1], cutoff: 20
As I said, not elegant, but it’s a kludge that works.
I’m building a library of useful methods that make life easier in sonic pi, including lfos, envelopes, trancegates, easy transposing of pitched samples, etc. But I’m bogged down debugging a huge complex method for arranging multiple voices. Once I got the bugs out, I’ll be putting it on github and sharing it here. Hopefully in a week or so.