Yo, would you have any suggestion on how I could optimise the idxs
calculation using the recursion operator?
This would be my first step I suppose...
Alessandro

Il giorno mer 13 gen 2021 alle ore 11:02 Stéphane Letz <l...@grame.fr> ha
scritto:

> Thanks.
>
> Then I would suggest to simplify the code as much as possibly to
> understand where those 1344 inputs come from. You can possibly use the «
> faust2firefox foo.dsp »  tool to display the block diagram and better
> understand what happens.
>
> Stéphane
>
> > Le 13 janv. 2021 à 10:44, Alessandro Anatrini <al.anatr...@gmail.com> a
> écrit :
> >
> > Hi Stéphane,
> > thanks for the answer. Wow that's definitely too much code. I'll copy
> paste again the oscillator code and comment each line.
> > I hope this will help, otherwise just let me know :))
> >
> > > os_wt(freq,wav,len,sr,steps,tab) = 0.5*((2.0*v1) + (-v0+v2)*dv +
> (2.0*v0 - 5.0*v1 + 4.0*v2 - v3)*pow(dv,2) + (-v0 + 3.0*v1 - 3.0*v2 +
> v3)*pow(dv,3)) // This is the formula to perform an uniform Catmull-Rom
> spline interpolation
> > > with {
> > >     counter = %(*:max(len))~+(freq*(len/sr)); // create a phasor with
> increment as function of freq to calculate the index of the interpolation
> > >     trig = ma.diffn(counter)<0; // 0 when phaze wraps at len else 1
> > >     phaze = @(counter,1); // 1s delay so it's in sync with trig
> > >
> > >     dv = ma.decimal(phaze); // this is the decimal index needed for
> the spline interpolation
> > >     wsel = sah(trig,rint(wav)); // this is used to select 1 of the 127
> morphing waves. The wave's corresponding number is passed through only when
> the counter wraps, or in other words when it reaches its maximum. This
> becomes useful if for example the position of wav will be modulated by a
> certain amount of a LFO. In this case this value would be added to the
> value of wav.
> >
> > >     bas = rint(wsel)*len; // this gives the position in samples of the
> selected wave inside the table. Where the first term is the int of the
> selected wave (1- 127) and len is the length in sample of a cycle, thus 256
> > >
> > >     blend_b = ma.decimal(wsel); // these calculations are then used to
> form the data of the spline interpolation. The decimal part will be 0. in
> this case since wsel is integer. But this will make sense in the future if
> the selected wave position (wav) will be modulated by a LFO for example
> > >     blend_a = 1-blend_b; // this therefore 1 (without wav modulation)
> > >     b_next = bas+len;
> > >
> > >     // It's here where all the inputs you mentioned are created. As
> you can see idxs 2,3 and 4 are generated recursively. If I'm not wrong the
> math should be correct, but probably this could be rewritten in a more
> proper way...
> > >     idx1 = wrap(phaze-1.0,0.0,len);
> > >     idx2 = idx1 <: _+1-(len*(_>=255.0));
> > >     idx3 = idx2 <: _+1-(len*(_>=255.0));
> > >     idx4 = idx3 <: _+1-(len*(_>=255.0));
> > >
> > >     // And here I used the previous indexes to create the values of
> the 4 points needed for the spline interpolation and thus, this will
> generate other more inputs...
> > >     v0 = 0,(blend_a*(idx1+bas)) + (blend_b*(idx1+b_next)) : tab; //
> without an LFO modulating the position of (wav) the second term of sum will
> be 0
> > >     v1 = 0,(blend_a*(idx2+bas)) + (blend_b*(idx2+b_next)) : tab;
> > >     v2 = 0,(blend_a*(idx3+bas)) + (blend_b*(idx3+b_next)) : tab;
> > >     v3 = 0,(blend_a*(idx4+bas)) + (blend_b*(idx4+b_next)) : tab;
> > > };
> >
> >
> >
> >
> >
> >
> > Il giorno mer 13 gen 2021 alle ore 09:27 Stéphane Letz <l...@grame.fr>
> ha scritto:
> > Hi Alessandro,
> >
> > I’m not sure to follows all the details of your code, but compiling it
> in C++, it generates a DSP with 1344 inputs (!!), 1 output, and 11884 lines
> of code. So something is probably wrong.
> >
> > Can you possibly explain it more, and/or comment the code in details ?
> >
> > Thanks.
> >
> > Stéphane
> >
> >
> > > Le 12 janv. 2021 à 20:01, Alessandro Anatrini <al.anatr...@gmail.com>
> a écrit :
> > >
> > > Hi all,
> > >
> > > I’m quite new to faust and I’m facing some issues implementing a
> wavetable oscillator.
> > > The table I’m using is made of 127 morphing waves of 1 cycle each,
> with each cycle of 256 samples.
> > > An instance of the oscillator sounds quite fine. When I try to run 2
> instances, it still compiles on FaustLive, but it doesn’t run anymore. By
> this I mean that it really doesn’t run because the CPU drops around 2%,
> while it should be much higher. Using par primitive in order to run 2
> instances of the same osc still gives me the same issue.
> > > I paste here below the code I' working on.
> > >
> > > Any ideas what I might be doing wrong?
> > > Thanks for your suggestions,
> > > Alessandro
> > >
> > >
> > >
> > > import("stdfaust.lib");
> > >
> > > os_freq_a = hslider("Freq_A [style:knob]",20,20,2000,0.01) : si.smoo;
> > > os_wav_a = hslider("Sel_A [style:knob]",0,0,127,1) : si.smoo;
> > >
> > > os_freq_b = hslider("Freq_B [style:knob]",20,20,2000,0.01) : si.smoo;
> > > os_wav_b = hslider("Sel_B [style:knob]",0,0,127,1) : si.smoo;
> > >
> > > volume = hslider("Volume [style:knob]",0,0,1,0.01) : si.smoo;
> > >
> > > tab1 =
> soundfile("Set_1[url:{'/Users/alan/wavesets/sin_doubler1.wav'}]", 1) :
> !,!,_;
> > > tab2 =
> soundfile("Set_2[url:{'/Users/alan/wavesets/sin_doubler2.wav'}]", 1) :
> !,!,_;
> > >
> > > wrap(val,lo,hi) = ba.if(val<lo, fmod(hi-(lo-val),(hi-lo)),
> fmod(lo+(val-lo),(hi-lo)));
> > > sah(trg,x) = (*(1 - trg) + x * trg) ~ _;
> > >
> > > os_wt(freq,wav,len,sr,steps,tab) = 0.5*((2.0*v1) + (-v0+v2)*dv +
> (2.0*v0 - 5.0*v1 + 4.0*v2 - v3)*pow(dv,2) + (-v0 + 3.0*v1 - 3.0*v2 +
> v3)*pow(dv,3)) // Catmull-Rom spline interpolation
> > > with {
> > >     counter = %(*:max(len))~+(freq*(len/sr)); // create a phasor with
> increment as function of freq
> > >     trig = ma.diffn(counter)<0; // 0 when phaze wraps at len else 1
> > >     phaze = @(counter,1); // 1s delay so it's in sync with trig
> > >
> > >     dv = ma.decimal(phaze);
> > >     wsel = sah(trig,rint(wav));
> > >     bas = rint(wsel)*len;
> > >
> > >     blend_b = ma.decimal(wsel);
> > >     blend_a = 1-blend_b;
> > >     b_next = bas+len;
> > >
> > >     idx1 = wrap(phaze-1.0,0.0,len);
> > >     idx2 = idx1 <: _+1-(len*(_>=255.0));
> > >     idx3 = idx2 <: _+1-(len*(_>=255.0));
> > >     idx4 = idx3 <: _+1-(len*(_>=255.0));
> > >
> > >     v0 = 0,(blend_a*(idx1+bas)) + (blend_b*(idx1+b_next)) : tab;
> > >     v1 = 0,(blend_a*(idx2+bas)) + (blend_b*(idx2+b_next)) : tab;
> > >     v2 = 0,(blend_a*(idx3+bas)) + (blend_b*(idx3+b_next)) : tab;
> > >     v3 = 0,(blend_a*(idx4+bas)) + (blend_b*(idx4+b_next)) : tab;
> > > };
> > >
> > > os_wt_a = os_wt(os_freq_a,os_wav_a,256,ma.SR,127,tab1);
> > > os_wt_b = os_wt(os_freq_b,os_wav_b,256,ma.SR,127,tab2);
> > >
> > > process = os_wt_a,os_wt_b :> _*volume;
> > >
> > >
> > > _______________________________________________
> > > 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