I am posting this here because it is more algorithmically related than C++ related (especially since I am not writing this program in C++ anyways). I am working on this project right now in which I am using fast fourier transforms and convolving two audio files together into one.

For example, I have an audio file of a person speaking, and then I have a filter audio file from a parking garage, and I convolve them together to make it sound like the person is speaking inside of a parking garage.

I am inputting the audio signals and then using the FFT on both the signal and the filter. From there I need to convolve them, and then do an inverse-FFT to get back to an audio signal, and then write that to a file.

The part that I am getting held up on is the actual convolving (the multiplying of the two signals together).

Basically it is like polynomial multiplication:

Here is some pseudo code:

Now...here is my question: how does this work if A and B are different sizes? Obviously A (the audio file) could be something like 10 seconds long...but the filter file only 2 or 3 seconds...and therefore the arrays of data will be of different length.Code:Array audio_file = loadMusicSignalFile(file one); Array filter_file = loadMusicSignalFile(file two); A = FFT(audio_file); B = FFT(filter_file); Array C; for each element of A: C[x] = A[x] * B[x]; final_audio = inverse_FFT ( C );

Should I just pad the filter array with zeros, or is there a better way to do it, such as repeating the filter until it is the same length as the audio file? There is also the issue of the fact that in order to properly do an FFT, the array passed to the FFT needs to have a length of a power of 2...but that isn't difficult. In order to do that, I know that I can just pad with zeros. I just wasn't sure how I should properly make A and B of equal length.

Any suggestions?