re: random value

These are all great solutions.  I didn't expect to see such good answers to
this problem.  I tried various other approaches too, such as writing the
output of noise to a table, and then accessing the table values using a
phasor but I couldn't quite figure out how to write the random values to a
table and access it all in the same block.  Also worked with ffunctions
too, but alot of the stdlib tools use types which need recasting for Faust,
so's I gave up with that approach.

Be happy to see a primitive, if/when it comes about.

Regards,
Bob

On Thu, May 6, 2021 at 9:33 AM James Mckernon <[email protected]> wrote:

> Hi Dario,
>
> On 5/6/21, Dario Sanfilippo <[email protected]> wrote:
> > Even if calling an external random function, don't you always have the
> > problem of calling it with a different seed each time to get a different
> > stream at each run?
>
> Attached is my code relating to this. There's a c++ function, which
> takes a dummy argument and returns a random value, and two faust
> randomness functions which take such a random value as a seed. One is
> a continuous noise function (like no.noise), and the other one takes a
> trigger and outputs a new random value when triggered. (rn.dsp should
> really be called rn.lib, but I had to rename it to defeat some weird
> filtering gmail applies to attachments.)
>
> These output in the full integer range, so I also included some
> scaling functions, rndscale, which takes a maximum value to scale its
> input down to, and rndtorange, which takes a maximum and minimum. And
> there are rndscaleint and rndtorangeint which take the same arguments
> and output integers.
>
> Usage would be something like:
>
> // continuous (white) noise
> import("rn.lib");
> process = rnd(0) : intnoise : rndtorange(10, 20);
>
> // triggered noise
> ba = library("basics.lib");
> trig = ba.pulse(2);
> process = rnd(0),trig : rng : rndtorange(10, 20);
>
> // multiple noise streams (note distinct dummy arguments for distinct
> calls to rnd)
> process = first,second,third with {
>     first  = rnd(0) : intnoise : rndtorange(10, 20);
>     second = rnd(1) : intnoise : rndtorange(10, 20);
>     third  = rnd(2) : intnoise : rndtorange(10, 20);
> };
>
> I remembered why I found that it was better to just use foreign
> functions for a seed, and then iterate on that seed with faust
> functions: faust will treat a function with constant inputs as having
> a constant output. In other words, it won't actually call a foreign
> function more than once over time if its inputs are constant.
>
> Hope that helps. Let me know if you've any questions.
>
> Cheers,
> James
> _______________________________________________
> Faudiostream-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
>
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to