Page 1 of 4

3 timers with loop

PostPosted: Fri Jan 26, 2018 7:09 pm
by Nicolas605
Hello,

I am new with FlowStone and I search how make a 3 timers with loop. I have 3 signal generators and I have multiplexer and switch for drive the sound. I want define the times with :

Slide T1 = time of the first generator play (time adjustable between 10s - 600s)
Slide T2 = time of the second generator play (time adjustable between 10s - 600s)
Slide T3 = time of the third generator play (time adjustable between 10s - 600s)

When we press the ON/OFF switch of the timer, we have T1,T2,T3,T1,T2,T3,T1...
If I have understand, the output of this timer must be 0,1,2,0,1,2,0 for drive the multiplex component.
0 when t=T1, 1 when t=T2, 2 when t=T3

I have search in the forum but I am lost with the counters.

Thank you for your help.

Nicolas.

Re: 3 timers with loop

PostPosted: Sat Jan 27, 2018 12:39 pm
by tulamide
Hi Nicolas,

I hope this does the job right?
I've made it so that you can change the amount of indices at any time (see schematic).

Just take note that it is not sample-precise timing. If you need that, it would require a blue stream solution, which would be a task for the DSP gurus :D

Re: 3 timers with loop

PostPosted: Sat Jan 27, 2018 3:02 pm
by Nicolas605
Hi Tulamide,

Thank you very much, it's perfect :)
I don't understand your code but I hope soon.

I must replace Duration per index with my Sliders. Slider 1 for duration 1, Slider 2 for duration 2 and Slider 3 for duration 3. How the Duration per index window send the time ?

Thank you.
Nicolas.

Re: 3 timers with loop

PostPosted: Sat Jan 27, 2018 4:44 pm
by Nicolas605
I found a solution with Str2Arr component and 3 in Width. But I can't do less than 100.
Have you a better option for String > Array for a number between 10 and 600 ?

Re: 3 timers with loop

PostPosted: Sat Jan 27, 2018 8:55 pm
by ChrisHooker
Attached is a solution in blue. (You will need to enable the ASIO Output (or replace with a Direct Sound Out) in order for the code to run.)
I've set up the code so that you can test it using the "count" slider to the right of the code box - all you need to do is replace the occurrences of "counter" in the code's "index" line with the word "count".

Note that Multiplexer primitives are green and cannot be driven by a blue stream connection (therefor are not sample accurate), so if sample accuracy is needed (and/or you wish to prevent pops in the audio during switching) you will need to drive the split in blue/stream. For this, I've set up a secondary code block, followed by multipliers (which could also use dezippers if you wish to smooth the switching). All of this could be combined into one code block (and probably someone could optimize it with assembler), but I wanted to leave it all broken out for simplicity of understanding the flow.

Re: 3 timers with loop

PostPosted: Sat Jan 27, 2018 9:10 pm
by tulamide
I'm not quite sure about your issue. Basically you build a float array with the float array prim. If you can't manage to get it done, report back, post a schematic with the issue and I'll give it a try then.

@ChrisHooker:
Wow, that is really nice! Especially useful if you don't need a multiplexer. This deserves to be refined, so if somebody would hop in - it would be appreciated!

Re: 3 timers with loop

PostPosted: Sat Jan 27, 2018 10:21 pm
by Nicolas605
@Tulamide
Thank you, Excuse me for my understanding of FlowStone. Ruby is new and I search C ... I have not need precision but may be later, a audio fader when the multiplexer change the source. Your solution is very good. I take pictures with fsm file tomorrow.

Hello Chris, Thank you, I have tested your file but with crash for me. My project freeze when I add your component. I have ASIO output and 3% CPU working with the original file project. I have 3x2(setero) input with 1 stereo output. 3 Switch for select 1 or 2 or 3 like the "Solo" on the mixing hardware. When I have not solo, I can push on the switch of "Timer" for 1=time of Slider 1 and after 2=time of Slider 2 and after that 3=time of Slider3 and loop for 1 ect ...

FlowStone is very great and I found a new world, but I have need some time for understand.

Re: 3 timers with loop

PostPosted: Sun Jan 28, 2018 12:19 am
by ChrisHooker
I forgot to hook up the on/off switch!

Here's a revised/condensed version, all in one code block (not as easy to see how it works), with opportunity to expand with dezipping (the code to do that is where I would have to think for a bit).

With the on/off switch implemented comes the next question: what should happen to the signal when the counter is turned off? I've set it up here to set the output to Out0, and the counter resets to zero.

Re: 3 timers with loop

PostPosted: Sun Jan 28, 2018 1:05 am
by tulamide
ChrisHooker wrote:what should happen to the signal when the counter is turned off? I've set it up here to set the output to Out0, and the counter resets to zero.

That sounds reasonable! The stream has to go somewhere (or can it be prevented?), so the first output makes sense. In the Ruby version I've also set everything back to init, so "counter to zero" is the same behaviour.

I wouldn't know how to create effective dezip code yet, but I assume it would be some kind of crossfading over dezip time?

Re: 3 timers with loop

PostPosted: Sun Jan 28, 2018 2:19 am
by ChrisHooker
The stream has to go somewhere (or can it be prevented?)


Yes, it could easily be prevented! Changing the out line to include a mask will only allow a value to pass when "run" is active. This line would need to be used for all outs. [Edit: Actually, I take that back - it's only needed on out0, since when not running, the other outputs are already silenced, due to the counter being reset.]
Code: Select all
out0=(run==1) & (in*amp0)


My idea for the stream-code dezip would be to have the "amp" in my code slide from 0-1 or 1-0.
For example, as amp0 switches from 1 to 0, amp1 simultaneously switches from 0-1... These switches would trigger a new counter to start, which counts up to the user-defined # of samples (or back down to zero). The dezipped amp would then multiply the input by a value between 0-1 based on % of completion of the counter. As both amps are changing over this same period of time, the result would be a linear crossfade.