# Applying a frequency filter in dB onto an audio wav file in the frequency domain

I am working on a university project consisting of a C program supposed to apply a correction of the isophonic curves to an audio PCM file.

So far, I have managed to code the most part of it (read/write of a wave file, 1D complex FFT with fftw, overlap-add method, however not sure about the accomplishment of this one), but I am struggling on the part where I am supposed to apply the correction.

I understood that a convolution of two signal into the time domain is equal to a product of the spectrum into the frequency domain, and that the overlap-add method is necessary in order to have a linear convolution instead of a circular one: because our signal is not repetitive, it is music.

My filter is under the form of a spectrum, from 0 to the half of the fft size (because, correct me if I'm wrong, but the first half of the output (0 to (*buffer_size/2)) from the 1D complex FFT is made of the positive frequencies, and the other half ((*buffer_size/2) to (*buffer_size)) of the negative frequencies (in backward order). And the amplitude of the different frequencies of this filter are under the form of dB to apply.

I am currently using a 24bits 48kH whitenoise (so I can witness if the frequency gain is correctly applied) file with a buffer size of 4096 samples and a 50% overlap. According to my understanding, I wrote this incomplete code :

for(i=0; i<(*buffer_size/2); i++){      //The positive frequencies

to_apply = c_matrice->c[i][curve2apply];

dft_freq_L[i] = dft_freq_L[i] (?) to_apply;  //real
dft_freq_L[i] = dft_freq_L[i] (?) to_apply;  //imaginary

dft_freq_R[i] = dft_freq_R[i] (?) to_apply;
dft_freq_R[i] = dft_freq_R[i] (?) to_apply;
}

for(i=(*buffer_size/2); i<(*buffer_size); i++){      //The negative frequencies

to_apply = c_matrice->c[i][curve2apply];

dft_freq_L[(*buffer_size)-i] = dft_freq_L[(*buffer_size)-i] (?) to_apply;
dft_freq_L[(*buffer_size)-i] = dft_freq_L[(*buffer_size)-i] (?) to_apply;

dft_freq_R[(*buffer_size)-i] = dft_freq_R[(*buffer_size)-i] (?) to_apply;
dft_freq_R[(*buffer_size)-i] = dft_freq_R[(*buffer_size)-i] (?) to_apply;
}


So here are a few questions :

• How do I convert and apply my filter spectrum in dB onto the spectrum of the signal? What kind of relation is there between the level of the time based signal and the level of its spectrum ? (Knowing that Parseval's law tells us that the power of the spectrum is equal to the power of the time based signal, if I'm correct)

• This project is made for testing and learning purposes, but does trying to compensate the isophonic curves with a real time system (which therefore always knows the level in dB SPL you are getting) makes any sense to you ?

My goal is not to obtain a perfect result that can be listened (I have come to think that it is a futile quest), but just to get a "theoretically correct" method. Here is a preview of the curves I try to apply : 