Page 1 of 1
Stream Greater Than ...
Posted: Mon Jul 22, 2013 3:54 am
by steph_tsf
Hello, I can't figure how to use the "Stream Greater Than" primitive, comparing two Streams.
See attached .fsm.
There is a DSP code trying to generate a recurrent Pulse (sorte of Dirac). That part is almost fine.
I want the DSP code to generate a Green Trigger each time a Dirac gets pulsed, for triggering the "Scope" primitive.
This way the scope runs in sync with the Dirac.
For generating such trigger, the DSP code is outputting a second stream, that one is a "dummy" constant 0.25 signal.
The idea is to rely on the "Stream Greater Than" primitive, comparing the two Streams (the Dirac and Dummy), automatically generating a "Green Trigger", possibly eating little CPU resource.
Surely there is something important I have not understood.
Any help much appreciated.
Steph.
Re: Stream Greater Than ...
Posted: Mon Jul 22, 2013 4:26 am
by nix
Hey steph,
you have run into a data type problem.
The stream prims are incompatible with the green 'on true'.
I'm not exactly sure what to do to achieve your functionality.
Will have a look.
One thing that may help is that green->blue works,
just not blue->green
Re: Stream Greater Than ...
Posted: Mon Jul 22, 2013 10:18 am
by Tronic
conceptually, the greens and blues can not work together at samplerate.
the blue must always be grabbed with a primitive mono to sample,
and then sampled at a lower frequency, using a green tick generator or a ruby clock.
in this case it is better to make a comparison in blue, and convert the boolean in green,
this does not guarantee an accurate result at the sampling frequency.
But you could do with a ruby sampling using the Frame class, and from it generate the trig.
this should be in sync with the blue, with a buffer equal to your buffer driver of your sound card.
you can find an example here.But if your goal and do not have a trig accurate,
just use a single primitive mono to sample after the comparison in blue to convert it to green, and generate the trig.
Re: Stream Greater Than ...
Posted: Mon Jul 22, 2013 3:37 pm
by steph_tsf
nix wrote:Hey steph, one thing that may help is that green->blue works, just not blue->green
A solution is to rely on a Green triggered Blue Dirac generator. In other words, the master trigger would be a Tick25 (possibly divided by five) used as input for the Dirac Blue code.
The first difficulty is to transform a trigger in something that can be read, reliably, by the Blue DSP Code.
The second difficulty is to write Blue code (i86 condition and mask) implementing the required if/then structure.
Using a flip-flop done in Green I can transform the Tick25 (trigger) into a Float equal 0.0 during 100 ms, and equal 1.0 during the next 100 ms, and this will be the Green sync signal entering the Blue DSP code implementing the Dirac.
The Blue DSP code of the Dirac would read the sync and do :
set the tmp variable to zero
if (new sync <> old sync) then : set tmp variable to one : end
output the tmp variable as audio (it will thus be a one during one sample, if we just experienced a trigger change)
Can you show an example?
Re: Stream Greater Than ...
Posted: Mon Jul 22, 2013 4:35 pm
by Tronic
steph_tsf wrote:The Blue DSP code of the Dirac would read the sync and do :
set the tmp variable to zero
if (new sync <> old sync) then : set tmp variable to one : end
output the tmp variable as audio (it will thus be a one during one sample, if we just experienced a trigger change)
Can you show an example?
Code: Select all
streamin Trigger; // 0<1 flip-flop
streamout Pulse; // out 1 only one sample
float Last;
Pulse=(Trigger!=Last)&1;
Last=Trigger
Re: Stream Greater Than ...
Posted: Mon Jul 22, 2013 5:20 pm
by steph_tsf
Thanks for the example, very efficient. I let you compare with what I've been fiddling!
Re: Stream Greater Than ...
Posted: Mon Jul 22, 2013 6:12 pm
by Tronic
to use my code
you could replace your flip flop with this.

- green flip flop with reset state
- flip_flop.JPG (25.5 KiB) Viewed 14961 times