Hi Stephen,

The third input signal of rdtable is the read index. In your case it should be 
an integer 
signal with values in the interval [0..2047]. But in your example cnt will 
generate reads 
outside the boundaries of the table causing segfaults. In other words you 
should use a 
phasor as read index. You can have a look at osc in music.lib...

Cheers

Yann


Le 13/05/2014 18:08, Stephen Sinclair a écrit :
> Hello,
>
> I've been struggling a bit with the semantics of rdtable().  I'm using
> the plot.cpp architecture for testing my functions, and piping the
> data into python/matplotlib for visualization.  I'm not sure if I've
> encountered a bug or if it is my misunderstanding of how rdtable()
> works.
>
> Trying to create a simple "sin" wavetable oscillator, starting with
> the following definitions,
>
> phasor = ((+(1) : %(2048)) ~_);
> cnt = int(+(1)  ~ _ : -(1));
> func = (_/2048*2*PI - PI) : sin;
> tab = rdtable(2048, func, cnt);
>
> then the following process generates the phasor just fine:
>
> process = phasor;
> result: http://imgur.com/CWPsWsw
>
> However, if I try to index the table, I get:
>
> process = phasor : tab;
> result: http://imgur.com/bOokZNF
>
> So... it starts outputting zeros instead of the sine values, and then
> segfaults after just over 2500 samples.  I don't understand why, since
> the definition of the phasor contains a modulo 2048.  The same thing
> happens if I replace the % with fmod().
>
> Looking into the generated code, in the first process I get the
> following compute():
>
> FAUSTFLOAT* output0 = output[0];
> for (int i=0; i<count; i++) {
>    iRec0[0] = ((1 + iRec0[1]) % 2048);
>    output0[i] = (FAUSTFLOAT)iRec0[0];
>    // post processing
>    iRec0[1] = iRec0[0];
> }
>
> In the second case, when the table is involved, I get:
>
> FAUSTFLOAT* output0 = output[0];
> for (int i=0; i<count; i++) {
>    iRec1[0] = (1 + iRec1[1]);
>    output0[i] = (FAUSTFLOAT)ftbl0[int((iRec1[0] - 1))];
>    // post processing
>    iRec1[1] = iRec1[0];
> }
>
> You can see that the modulo appears to have disappeared and the table
> is accessed beyond the end.  I assume the compiler is trying to
> optimise the modulo out of the compute() function since it is trying
> to guarantee the range at compile time, but it seems wrong, and is
> causing segfaults.  I tried using max() and min() to guarantee the
> range but these mysteriously don't appear in the compute() function
> either, however they do appear in the fill() function.
>
> Any idea what is going on here?
>
> I'm working with faust/master.  Wanted to try faust2 but couldn't get
> it to compile.  (During stage, "Linking CXX executable faust")
>
> thanks,
> Steve
>
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> _______________________________________________
> Faudiostream-devel mailing list
> Faudiostream-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/faudiostream-devel
>


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Faudiostream-devel mailing list
Faudiostream-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-devel

Reply via email to