I will implement four equations first in javascript and later in go. My problem is i'm not a Mathematician, i don't know how to read the equations.
First one is the FFT window Blackman.
Second is an FFT algorithm:
Third is Smoothing over time:
Fourth is to decibel:
I don't can use a fft library for this job, it's required to implement this four equations. When the work is done i will run this four equations in this sequence on the same signal.
Can anyone help and explain how i come from the equations to working code? I don't know where i should start.
Thank you for each answer
This is in javascript. Make the appropriate changes for Go as well. I've not tested everything, just translated the math equations into code. If there are errors please correct the answer.
var pi = 3.14;
var blackmann = function(N){
var a = 0.16;
var a0 = (1-a)/2, a1 = 1/2, a2 = a/2;
var w = [];
for (var i=0; i<N, i++){
w[i] = a0 - a1*Math.cos(2*pi*i/N) - a2*Math.cos(4*pi*i/N);
}
return w;
}
var fft = function(x, K){
var X1 = [], X2 = [];
var N = x.length;
// X1 for the real spectrum, X2 for the imaginary part.
// For magnitude spectrum take |X1^2 + X2^2|
// For a K point fft
for (var k=0; k<K; k++){
for (var n=0; n<N; n++){
X1[k] = Math.cos(2*pi*n/N);
X2[k] = Math.sin(-2*pi*n/N);
}
}
return {"real":X1, "img":X2}
}
var smooting = function(x){
var s = [], t = 0.16
s[0] = x[0];
for (var i=1; i<x.length; i++){
s = t*s[i-1] + (1-t)*x[i]
}
return s
}
var decibel = function(X){
var Y = [];
for (var i =0;i<X.length(); i++){
Y[i] = Math.log10(Math.abs(X[i]));
}
return Y;
}