Need a Ruby float array solution

For general discussion related FlowStone
Post Reply
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Need a Ruby float array solution

Post by kortezzzz »

Hi,

I'm trying to find a simple ruby solution that would replace the whole array values to my own value. For instance, if the array is:

0.5
0.7
0.6
0.4

I would like to replace the whole bunch of values with 0.1 to end up with:

0.1
0.1
0.1
0.1

Why is it needed? because while FS's multisample module extracts the sfz file's values correctly, it yet doesn't allow determining them with knobs, so I can't prevent fundamentals values like "release=29" to be streamed... moreover, for instance, if I would like to customize the each of the AHDSR array values with my one desired values (with knobs), I have no way to control the arrays correctly. Any suggestions?
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Need a Ruby float array solution

Post by tulamide »

I can only answer the Ruby part. There's a method for arrays, called fill. It takes an object as parameter.

Code: Select all

ary = 0.5, 0.7, 0.6, 0.4
ary.fill(0.1)
# Now the array is [0.1, 0.1, 0.1, 0.1]


If you create a float array input and a float input, and name them "array_in" and "float_in", plus a float array output, then this code should work:

Code: Select all

def event i, v
    a = @array_in
    a.fill(@float_in)
    output a
end


This will activate whenever you change the float array at input or the float you wish the array to fill with.
"There lies the dog buried" (German saying translated literally)
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Re: Need a Ruby float array solution

Post by kortezzzz »

Thanks tulamide, works perfectly and now, each aspect of the multisample module can be controlled manually :D
Post Reply