I'd prefer a real fix to this issue. Piping signals into rand is also
tricky because they also need to be unique otherwise pure function
invocations are optimized.
Having just pure functions and functions with side effects would be easier.
On Fri, Apr 25, 2014 at 12:15 AM, Julius Smith <j...@ccrma.stanford.edu>wrote:
> Well it IS being called at the sampling rate, but it's apparently
> assumed to have the same value/side-effects at any given time instant.
> Therefore, it's called only once per sample no matter how many places it is
> used in the block diagram.
>
> It should work to give your rand function a signal argument (that it
> ignores) and pass different signals through different instances:
>
> ...
> fn = ffunction(int rand(float), <math.h>, "")/RAND_MAX;
> process = fn,fn,fn,fn;
>
> I suppose this is a bit of a hack, making the faust2firefox block-diagrams
> unnecessarily messy.
>
> - Julius
>
>
> At 01:31 PM 4/24/2014, Timo Westkämper wrote:
>
> 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 <j...@ccrma.stanford.edu >
> 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
> Faudiostream-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
>
>
>
> Julius O. Smith III <j...@ccrma.stanford.edu >
> Professor of Music and, by courtesy, Electrical Engineering
> CCRMA, Stanford University
> http://ccrma.stanford.edu/~jos/
>
>
> Julius O. Smith III <j...@ccrma.stanford.edu>
> 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
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users