Help: Ruby 4 x Sample & Hold Value

For general discussion related FlowStone
User avatar
Walter Sommerfeld
Posts: 250
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany
Contact:

Help: Ruby 4 x Sample & Hold Value

Post 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 :o
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 :(
Attachments
Walters dice 4 x Value Sample.fsm
(please ignore the simple dice part)
(264.29 KiB) Downloaded 834 times
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Help: Ruby 4 x Sample & Hold Value

Post 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
User avatar
Walter Sommerfeld
Posts: 250
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany
Contact:

Re: Help: Ruby 4 x Sample & Hold Value

Post 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
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Help: Ruby 4 x Sample & Hold Value

Post 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
User avatar
Walter Sommerfeld
Posts: 250
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany
Contact:

Re: Help: Ruby 4 x Sample & Hold Value

Post 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
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Help: Ruby 4 x Sample & Hold Value

Post 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.
Attachments
selection.fsm
(4.46 KiB) Downloaded 809 times
"There lies the dog buried" (German saying translated literally)
User avatar
Walter Sommerfeld
Posts: 250
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany
Contact:

Re: Help: Ruby 4 x Sample & Hold Value

Post 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...
User avatar
Walter Sommerfeld
Posts: 250
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany
Contact:

Re: Help: Ruby 4 x Sample & Hold Value

Post 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
4 Values s&h in ruby by sunsynth.fsm
finally it is working (i hope)
(15.54 KiB) Downloaded 793 times
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Help: Ruby 4 x Sample & Hold Value

Post 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
User avatar
Walter Sommerfeld
Posts: 250
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany
Contact:

Re: Help: Ruby 4 x Sample & Hold Value

Post by Walter Sommerfeld »

works fine... but:

where my version triggers one time after hit go - yours produces 3!

cheers,
Walter
Post Reply