hey japina,
you should probably try to get familiar with the composition operators (:, <:, 
:>, ~, etc.) to get a deep understanding of how these things are built up. 
especially the recursive operator can be a bit tricky to understand, but is 
very enlightening when you finally wrap your head around it. based on the faust 
manuals chapter around the modulo primitive 
(https://faust.grame.fr/doc/manual/index.html#modulo-primitive 
<https://faust.grame.fr/doc/manual/index.html#modulo-primitive>), this could 
probably deliver what you are after: 

cycle(N) = _~+(1) : -(1) : %(N);
process = select2(cycle(200) < 100, -1, 1);

it recursively adds 1 to a signal, takes the modulo of 200 of it so it is 
counting infinitely from 0 to 199.
then it outputs -1 if the signal is below 100 and 1 otherwise.

hope this helps
best josh



> On 9. Aug 2019, at 14:47, Japina <bost...@japina.eu> wrote:
> 
> I still can’t understand how the programming works in Faust in relation to 
> samples. Just for me to understand it I wanted to create a script that 
> changes output value at certain time.
> I know that such function already exists, but I would like to understand how 
> code works in relation to time :)
> 
> The idea is every 100 samples change output from 1 to -1 and back (so square 
> signal). The code I’ve came up to is:
> 
> out_value = 1.0;
> val = ba.if(ma.modulo(ba.time, 100) == 0, -out_value, out_value);
> process = val;
> 
> But what I get is just one sample with negative value and not additional 100 
> samples. 
> So I guess my assumptions about how Faust is working are wrong, but I just 
> can’t get the idea how to do it.
> 
> Any suggestions?
> 
> Thanks.
> 
> B._______________________________________________
> Faudiostream-users mailing list
> Faudiostream-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/faudiostream-users

_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to