View Single Post
Old 11-06-2018, 09:33 AM   #2
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 643
Default

Quote:
Originally Posted by Revoan View Post

Output[n] = (input[n]+input[n-1]+input[n-2])/3

Do I insert its as:

spl0 = (0.5*(ip0+prev0)+0.5((ip0+prev0-1)+0.5*(ip0+prev0-2))/3

No, this will not work. "prev0-1" simply subtracts 1 from prev0.


Have a look. Maybe it helps:


Code:
@init
bpos=0;
ip0=0; // initialise our variables to 0, so they are ready to use first time around the sample loop
ip1=0;

prev0_1=0;    // Init n-1
prev1_1=0;
prev0_2=0;    // Init n-2
prev1_2=0;

@slider

@block

@sample
ip0 = (10^(slider1/20))*spl0; // use slider position (dB scale) to control input level
ip1 = (10^(slider1/20))*spl1;

spl0=1/3*(ip0+prev0_l+prev0_2); // use of n, n-1 and n-2
spl1=1/3*(ip1+prev0_l+prev1_l);

prev0_2=prev0_l; // store n - 2
prev1_2=prev1_2;
prev0_l = ip0;      // store n - 1
prev1_l = ip1;
Please note that the first and second call to function "sample" work with null pre filled data. The 3rd call and onwards uses data from spl.
__________________
www.tbproaudio.de

Last edited by TBProAudio; 11-06-2018 at 09:39 AM.
TBProAudio is offline   Reply With Quote