Stream Greater Than ...

For general discussion related FlowStone
Post Reply
steph_tsf
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Stream Greater Than ...

Post 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.
Attachments
Stream Greater Than.fsm
(9.02 KiB) Downloaded 993 times
Stream Greater Than.png
Stream Greater Than.png (48.5 KiB) Viewed 15020 times
User avatar
nix
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Stream Greater Than ...

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

Re: Stream Greater Than ...

Post 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.
steph_tsf
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Stream Greater Than ...

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

Re: Stream Greater Than ...

Post 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
steph_tsf
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Stream Greater Than ...

Post by steph_tsf »

Thanks for the example, very efficient. I let you compare with what I've been fiddling!
Attachments
Synched Dirac.png
Synched Dirac.png (34.98 KiB) Viewed 14974 times
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Stream Greater Than ...

Post by Tronic »

to use my code
you could replace your flip flop with this.
green flip flop with reset state
green flip flop with reset state
flip_flop.JPG (25.5 KiB) Viewed 14965 times
Post Reply