Anes wrote:

RC and dt what are those values?? Searching with google it seems to be a hz value. In that case what hz values should i use??

I don't understand why it returns a "y", i tought the propouse of this pseudo-code was filling an output buffer given an input buffer.

if i have 48 float "x" array samples i should get 48 float "y" arrays.

In the pseudocode snippet, the variable x is the input array of samples and the variable y is the output array of samples. The code does not modify the input array values. And, the input and output arrays will be the same length.

The for-loop does the filtering using 2 weights. Note that it uses y[i-1], a prior computed output sample. In the youtube video, this concept was demonstrated using time-delay blocks and taps.

Directly above the pseudocode snippet in the wiki link are some formulas you need. dt appears as delta T in those formulas. The cutoff frequency in Hz is defined as fc = 1/(2 * Pi * RC), which can be rearranged to RC = 1 / (2 * Pi * fc). Also, alpha = (2 * Pi * dt * fc) / (2 * Pi * dt * fc + 1) and fc = alpha / ((1 - alpha) * 2 * Pi * dt).

dt is the time between samples, the reciprocal of the sampling frequency (in Hz). This is just filtering code, not decimating code; as mentioned, the input and output sampling arrays are the same lengths.

Using the above formulas and definitions, the function could be rewritten to accept the input samples, the input sampling frequency and the cutoff frequency, instead of dt and RC.

Also, the function could be modified to process one sample at a time instead of array of input samples. From the input sampling frequency and the cutoff frequency, alpha can be computed ahead of time. The formula within the for-loop would be applied only once to transform a single input sample into an output sample. And, the computed output sample would have to be stored for the next time the function is called (substituted in place of y[i-1]).