Page 1 of 2
Help: Ruby 4 x Sample & Hold Value
Posted: Thu Jan 29, 2015 10:12 pm
by Walter Sommerfeld
Well... this Value thing in ruby makes me crazy...
I need ur help guys:
What i need are 4 sampled values... sounds easy but:
i can't get it to work
maybe it should be done all in one ruby part?!
and maybe i'm missing here something
So just simply click the dice 4 times and try to recall the sampled values with the knob

Re: Help: Ruby 4 x Sample & Hold Value
Posted: Thu Jan 29, 2015 11:32 pm
by Tronic
semplify all with this?
Code: Select all
watch 'number', number = [ [*1..6].sample, [*1..6].sample, [*1..6].sample, [*1..6].sample ]
number[@select] # the var @select is an ruby int input named select
Re: Help: Ruby 4 x Sample & Hold Value
Posted: Thu Jan 29, 2015 11:46 pm
by Walter Sommerfeld
Hi Tronic,
thanks but:
i only need a value selector that is working (see the not changing output label when u rotate the knob)
...ignore the dice part
Re: Help: Ruby 4 x Sample & Hold Value
Posted: Fri Jan 30, 2015 12:03 am
by Tronic
Yes the ruby connector not have the same concept of the green < - >, so you have retrigger it with the ruby.
However the my example is the simply version of your schematics, it act in the same manner, just use an knob to get the value of results.
Code: Select all
def event i
if i=="dice" # get trig from dice button?
output 0, a=[*1..6].sample
output 1, b=[*1..6].sample
output 2, c=[*1..6].sample
output 3, d=[*1..6].sample
@number = [a,b,c,d]
end
output 4, @number[@select] #@select is knob input value
end
Re: Help: Ruby 4 x Sample & Hold Value
Posted: Fri Jan 30, 2015 1:28 am
by Walter Sommerfeld
I need 4 sampled values selectable from the same value source!
Not four selectable random numbers.
The dice is only a simple 'generator' to get 4 values for the selector!...
Please have a closer look - Thanks again
Walter
Re: Help: Ruby 4 x Sample & Hold Value
Posted: Fri Jan 30, 2015 1:36 am
by tulamide
Walter Sommerfeld wrote:I need 4 sampled values selectable from the same value source!
Not four selectable random numbers.
The dice is only a simple 'generator' to get 4 values for the selector!...
Please have a closer look - Thanks again
Walter
Something like this?
EDIT: No, can't be what you're looking for, I just saw that Tronic already offered bqasically the same, meaning a selection is done by the knob from a pool of several values.
Re: Help: Ruby 4 x Sample & Hold Value
Posted: Fri Jan 30, 2015 10:24 am
by Walter Sommerfeld
YUP tulamide,
but thanks anyway...
U guys put me on the right track...
but i guessed it ends up with a selector made inside a ruby mod by using variables to mimic the S&H...
My intention
a selection is done by the knob from a pool of several values
here is needed because i have a very complex Midi Controller project where i need to S&H 4 banks of values so i don't have to calculate them every time again and again!
After ur hints and sleep over it i think i got it (on paper)...

Will report later...
Re: Help: Ruby 4 x Sample & Hold Value
Posted: Fri Jan 30, 2015 11:41 am
by Walter Sommerfeld
Here my working if/elsif version!
If some of u like to make a simpler version with in 'case' etc. - you're welcome...
keep on doing!
Walter
Re: Help: Ruby 4 x Sample & Hold Value
Posted: Fri Jan 30, 2015 3:36 pm
by Tronic
this is my simplification
Code: Select all
def init
@SH = []
end
def event i, v
if @on and (i=='go') and (@selection<=@max)
@SH[@selection] = @input_value
end
output @selection, @SH[@selection]
output 'done_v', nil
output 'done', nil
end
Re: Help: Ruby 4 x Sample & Hold Value
Posted: Fri Jan 30, 2015 5:33 pm
by Walter Sommerfeld
works fine... but:
where my version triggers one time after hit go - yours produces 3!
cheers,
Walter