Hi.
Based on the Faust documentation it should be treated as a function with
side effects:
"Foreign functions with input parameters are considered pure math
functions. They are therefore considered free of side effects and called
only when their parameters change (that is at the rate of the fastest
parameter).
Exceptions are functions with no input parameters. A typical example is the
C rand() function. In this case the compiler generate code to call the
function at sample rate."
http://faust.grame.fr/index.php/documentation/references/12-documentation/reference/48-faust-syntax-reference-art#tth_sEc3.4.5
So it looks like it shouldn't be optimized as it is now. While it is called
at sample rate, the parallel execution is not treated correctly.
Timo
On Thu, Apr 24, 2014 at 11:23 PM, Julius Smith <[email protected]>wrote:
> Maybe it should be possible declare "volatile" foreign functions that
> are not optimized in this way?
>
>
> At 03:26 AM 4/24/2014, Timo Westkämper wrote:
>
> Hi.
>
> Could I get a clarification concerning parameterless functions?
>
> I tried this code
>
> // stateless random generator
> rand = fn / RAND_MAX
> with {
> Â fn = ffunction(int rand(), <math.h>, "");
> Â RAND_MAX = fconstant(int RAND_MAX, <math.h>);
>
> };
>
> process = rand, rand, rand, rand;
>
>
> and got the following result
>
> Â Â virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT**
> output) {
>
> FAUSTFLOAT* output0 = output[0];
> FAUSTFLOAT* output1 = output[1];
> FAUSTFLOAT* output2 = output[2];
> FAUSTFLOAT* output3 = output[3];
> for (int i=0; i<count; i++) {
> float fTemp0 = (float(rand()) / float(RAND_MAX));
> output0[i] = (FAUSTFLOAT)fTemp0;
> output1[i] = (FAUSTFLOAT)fTemp0;
> output2[i] = (FAUSTFLOAT)fTemp0;
> output3[i] = (FAUSTFLOAT)fTemp0;
> }
> }
>
> I expected four random numbers in parallel.
>
> What is the right way to call rand() from Faust?
>
> Br,
> Timo
>
> ------------------------------------------------------------------------------
> Start Your Social Network Today - Download eXo Platform
> Build your Enterprise Intranet with eXo Platform Software
> Java Based Open Source Intranet - Social, Extensible, Cloud Ready
> Get Started Now And Turn Your Intranet Into A Collaboration Platform
> http://p.sf.net/sfu/ExoPlatform
> _______________________________________________
> Faudiostream-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
>
>
> Julius O. Smith III <[email protected]>
> Professor of Music and, by courtesy, Electrical Engineering
> CCRMA, Stanford University
> http://ccrma.stanford.edu/~jos/
>
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users