From e0643a05b822bc2b24b2b863df6a2eed3aa97291 Mon Sep 17 00:00:00 2001 From: ymherklotz Date: Thu, 8 Mar 2018 13:43:41 +0000 Subject: Added power domain --- Project/RTDSP/enhance.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'Project/RTDSP/enhance.c') diff --git a/Project/RTDSP/enhance.c b/Project/RTDSP/enhance.c index 7094773..5f2e1ad 100644 --- a/Project/RTDSP/enhance.c +++ b/Project/RTDSP/enhance.c @@ -81,7 +81,7 @@ DSK6713_AIC23_Config Config = { \ }; typedef struct { - float *mag_spec; + float *pow; float sum; } MVal; @@ -94,7 +94,10 @@ float *inwin, *outwin; /* Input and output windows */ float ingain, outgain; /* ADC and DAC gains */ float cpufrac; /* Fraction of CPU time used */ complex *fft_out; /* FFT output */ -float* noise; +float *noise; +float *power_in; +float *mag_in; + volatile int io_ptr=0; /* Input/ouput pointer for circular buffers */ volatile int frame_ptr=0; /* Frame pointer */ volatile int frame_ctr = 0; @@ -127,6 +130,8 @@ void main() inwin = (float *) calloc(FFTLEN, sizeof(float)); /* Input window */ outwin = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ fft_out = (complex *) calloc(FFTLEN, sizeof(complex)); /* FFT Output */ + power_in = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ + mag_in = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ /* initialize board and the audio port */ init_hardware(); @@ -136,7 +141,7 @@ void main() /* initialize algorithm constants */ - for (k=0;k MAX_COUNT-1) { int i; - float x_val; frame_ctr = 0; if(++m_ptr == NUM_M) m_ptr = 0; M[m_ptr].sum = 0; for(i = 0; i < FFTLEN; ++i) { - x_val = cabs(fft_out[i]); - M[m_ptr].mag_spec[i] = x_val; - M[m_ptr].sum += x_val; + M[m_ptr].pow[i] = power_in[k]; + M[m_ptr].sum += power_in[k]; } } // max(lambda, |N(w)/g(w)| for (k = 0; k < FFTLEN; ++k) { float g; - mag_N_X = 1 - alpha * noise[k]/cabs(fft_out[k]); + mag_N_X = 1 - alpha * noise[k]/power_in[k]; g = mag_N_X > lambda ? mag_N_X : lambda; fft_out[k] = rmul(g, fft_out[k]); } -- cgit