Slow Ruby Ramp Generator

For general discussion related FlowStone
Post Reply
User avatar
aronb
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA
Contact:

Slow Ruby Ramp Generator

Post by aronb »

Hi,

Is it possible to build a slow Ruby Ramp generator?

I have looked on the forum and tried to make one in Ruby but it crashes, pretty much on every try...
I need to make many random ramps that are slow, and was hoping I could do it in Ruby. I landed doing it in the DSP, but was wondering if slow waveforms can also be generated in Ruby as well ? ? ? And by slow I mean about 10 samples per second or so...

I forgot to save before I ran it - it crashed, but I took a screenshot :oops:

Failed Ruby Ramp...
Failed Ruby Ramp...
Ruby_Ramp.JPG (52.22 KiB) Viewed 10272 times


Thanks for any help or suggestions,

Aron
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Slow Ruby Ramp Generator

Post by KG_is_back »

yes, this can be done. However, I'm not sure what you're trying to achieve exactly, so here are my few attempts:

1. From the image I see it seems you what to generate a wavetable for a ramp.

Code: Select all

#inputs should be named "length" (float) and "tick" (trigger)
def event(i,v,t)
if i=="tick"

output 0, (0...@length).map{|i|
i.to_f/@length
}

end
end


2. If you want to generate a slowly changing green float output.

Code: Select all

#input should be named "on" (boolean) and "period" (float)

def event(i,v,t)
if @on
@dt=t - (@dt||t)

@ramp=(@ramp||0.0+@dt/@period)%1.0
output 0,@ramp
input 99,nil,time+0.1 #change this 0.1 to whatever tick speed you need.
else
@ramp=0.0
@dt=nil
end
end


this will generate ramp that goes from 0 to 1 in predefined period time.
User avatar
aronb
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA
Contact:

Re: Slow Ruby Ramp Generator

Post by aronb »

OK...

I entered the Ruby code and while it produces an output it is not a ramp. I am still working thru this... a few of the code lines do not make sense to me at all, but I AM NOT a Ruby coder, but I am learning.

The input 99 is a callback to the input for ???

Here is my code...

Ruby_Ramp_01.fsm
Ruby Ramp
(65.82 KiB) Downloaded 954 times


does this look correct? It just seems complex for something like an up counter, but again I am not a Ruby coder :shock:

And to answer a previous question, I need a float output NOT an array... I can get the array version working, but not the "Streaming Green" version.

Thanks again,

Aron
Post Reply