Hi folks. I’m currently working on some generative music and I’m trying to create a “CC controller” that controls the CC values of synths in another DAW. I’d like for the CC controller to ramp from one value to another, and occasionally oscillate between one and another; however, the jump from the current value of the CC to the “start” number of the ramp or oscillator can be quite stark, so I’m trying to figure out how to ramp from the current value to the starting value.
define :cc_controller do |cc_n, type, x, y, z|
if type == "flux" then
cc_v = (line x, y, steps: z).mirror.tick
midi_cc cc_n, cc_v
if cc_n == 1 then
set :cc1, cc_v
end
if cc_n == 2 then
set :cc2, cc_v
end
if cc_n == 3 then
set :cc3, cc_v
end
if cc_n == 4 then
set :cc4, cc_v
end
if cc_n == 5 then
set :cc5, cc_v
end
if cc_n == 7 then
set :cc7, cc_v
end
if cc_n == 8 then
set :cc8, cc_v
end
end
if type == "shift" then
/
if cc_n == 1 then
cc_v = (line get[:cc1], y, inclusive: true, steps: z).ramp
end
if cc_n == 2 then
cc_v = (line get[:cc2], y, inclusive: true, steps: z).ramp
end
if cc_n == 3 then
cc_v = (line get[:cc3], y, inclusive: true, steps: z).ramp
end
if cc_n == 4 then
cc_v = (line get[:cc4], y, inclusive: true, steps: z).ramp
end
if cc_n == 5 then
x = get[:cc5]
cc_v = (line get[:cc5], y, inclusive: true, steps: z).ramp
end
if cc_n == 7 then
cc_v = (line get[:cc7], y, inclusive: true, steps: z).ramp
end
if cc_n == 8 then
cc_v = (line get[:cc8], y, inclusive: true, steps: z).ramp
end
/
cc_v = (line get[:cc5], y, inclusive: true, steps: z).ramp
midi_cc cc_n, cc_v.tick
end
end
live_loop :cc_phrase, sync: :tick do
phrase = 0
if phrase == 0 then
cc_controller 5, "shift", 50, 90, 200
end
if phrase == 1 then
end
if phrase == 2 then
end
if phrase == 3 then
end
if phrase == 4 then
end
sleep 1
end
Above is my current code. I’ve tried many variations of “get” and “set,” but I think because the cc_phrase function is a live_loop, it’s breaking the code. Here’s the error message I commonly get:
Error on job 131: [buffer eval, line 296] - Thread death +--> :live_loop_cc_phrase
undefined method `to_f' for (ramp ring 62.0, 62.14070351758794, 62.28140703517588, 62.42211055276382, 62.562814070351756, 62.7035175879397, 62.84422110552764, 62.984924623115575, 63.12562814070352, 63.266331658291456, 63.4070351758794, 63.54773869346734, 63.688442211055275, 63.82914572864322, 63.969849246231156, 64.1105527638191, 64.25125628140704, 64.39195979899498, 64.53266331658291, 64.67336683417085, 64.8140703517588, 64.95477386934674, 65.09547738693468, 65.23618090452261, 65.37688442211055, 65.51758793969849, 65.65829145728644, 65.79899497487438, 65.93969849246231, 66.08040201005025, 66.22110552763819, 66.36180904522612, 66.50251256281408, 66.64321608040201, 66.78391959798995, 66.92462311557789, 67.06532663316582, 67.20603015075378, 67.34673366834171, 67.48743718592965, 67.62814070351759, 67.76884422110552, 67.90954773869346, 68.05025125628141, 68.19095477386935, 68.33165829145729, 68.47236180904522, 68.61306532663316, 68.7537688442211, 68.89447236180905, 69.03517587939699, 69.17587939698493, 69.31658291457286, 69.4572864321608, 69.59798994974875, 69.73869346733669, 69.87939698492463, 70.02010050251256, 70.1608040201005, 70.30150753768845, 70.44221105527639, 70.58291457286433, 70.72361809045226, 70.8643216080402, 71.00502512562814, 71.14572864321609, 71.28643216080403, 71.42713567839196, 71.5678391959799, 71.70854271356784, 71.84924623115577, 71.98994974874373, 72.13065326633166, 72.2713567839196, 72.41206030150754, 72.55276381909547, 72.69346733668343, 72.83417085427136, 72.9748743718593, 73.11557788944724, 73.25628140703517, 73.39698492462311, 73.53768844221105, 73.678391959799, 73.81909547738694, 73.95979899497488, 74.10050251256281, 74.24120603015075, 74.3819095477387, 74.52261306532664, 74.66331658291458, 74.80402010050251, 74.94472361809045, 75.08542713567839, 75.22613065326632, 75.36683417085428, 75.50753768844221, 75.64824120603015, 75.78894472361809, 75.92964824120602, 76.07035175879398, 76.21105527638191, 76.35175879396985, 76.49246231155779, 76.63316582914572, 76.77386934673368, 76.91457286432161, 77.05527638190955, 77.19597989949749, 77.33668341708542, 77.47738693467336, 77.6180904522613, 77.75879396984925, 77.89949748743719, 78.04020100502512, 78.18090452261306, 78.321608040201, 78.46231155778895, 78.60301507537689, 78.74371859296483, 78.88442211055276, 79.0251256281407, 79.16582914572865, 79.30653266331657, 79.44723618090453, 79.58793969849246, 79.7286432160804, 79.86934673366834, 80.01005025125627, 80.15075376884423, 80.29145728643216, 80.4321608040201, 80.57286432160804, 80.71356783919597, 80.85427135678393, 80.99497487437186, 81.1356783919598, 81.27638190954774, 81.41708542713567, 81.55778894472363, 81.69849246231155, 81.8391959798995, 81.97989949748744, 82.12060301507537, 82.26130653266331, 82.40201005025125, 82.5427135678392, 82.68341708542714, 82.82412060301507, 82.96482412060301, 83.10552763819095, 83.2462311557789, 83.38693467336684, 83.52763819095478, 83.66834170854271, 83.80904522613065, 83.9497487437186, 84.09045226130652, 84.23115577889448, 84.37185929648241, 84.51256281407035, 84.65326633165829, 84.79396984924622, 84.93467336683418, 85.07537688442211, 85.21608040201005, 85.35678391959799, 85.49748743718592, 85.63819095477388, 85.77889447236181, 85.91959798994975, 86.06030150753769, 86.20100502512562, 86.34170854271358, 86.4824120603015, 86.62311557788945, 86.76381909547739, 86.90452261306532, 87.04522613065326, 87.1859296482412, 87.32663316582915, 87.46733668341709, 87.60804020100502, 87.74874371859296, 87.8894472361809, 88.03015075376885, 88.17085427135679, 88.31155778894473, 88.45226130653266, 88.5929648241206, 88.73366834170855, 88.87437185929647, 89.01507537688443, 89.15577889447236, 89.2964824120603, 89.43718592964824, 89.57788944723617, 89.71859296482413, 89.85929648241206, 90.0):SonicPi::Core::RampVector (NoMethodError)
start = start.to_f
^^^^^
Did you mean? to_a
to_s
Line 296: C:/Program Files/Sonic Pi/app/server/ruby/lib/sonicpi/lang/core.rb:1846:in `line'
C:/Program Files/Sonic Pi/app/server/ruby/vendor/memoist-0.16.2/lib/memoist.rb:213:in `line'
eval:296:in `block (3 levels) in __spider_eval'
eval:305:in `block (3 levels) in __spider_eval'
C:/Program Files/Sonic Pi/app/server/ruby/lib/sonicpi/lang/core.rb:2233:in `block in live_loop'
C:/Program Files/Sonic Pi/app/server/ruby/lib/sonicpi/lang/core.rb:2253:in `block (2 levels) in live_loop'
C:/Program Files/Sonic Pi/app/server/ruby/lib/sonicpi/lang/core.rb:2168:in `block in loop'
C:/Program Files/Sonic Pi/app/server/ruby/lib/sonicpi/lang/core.rb:2164:in `loop'
C:/Program Files/Sonic Pi/app/server/ruby/lib/sonicpi/lang/core.rb:2164:in `loop'
C:/Program Files/Sonic Pi/app/server/ruby/lib/sonicpi/lang/core.rb:2251:in `block in live_loop'
C:/Program Files/Sonic Pi/app/server/ruby/lib/sonicpi/runtime.rb:1202:in `block (2 levels) in __in_thread'
Any help is appreciated!