Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Spectrum-inverse a sampled audio signal

I am looking for a simple (pseudo)code that spectrum-inverse a sampled audio signal. Ideally C++

The code should support different sample rates (16/32/48KHz).

like image 253
Lior Kogan Avatar asked Aug 19 '10 09:08

Lior Kogan


1 Answers

Mixing the signal by Fs/2 will swap high frequencies and low frequencies - think of rotating the spectrum around the unit circle by half a turn. You can achieve this rotation by multiplying every other sample by -1.

Mixing by Fs/2 is equivalent to mixing by exp(j*pi*n). If x is the input and y the output,

y[n] = x[n] * exp(j*pi*n) = x[n] * [cos(pi*n) + j*sin(pi*n)]

This simplifies easily because sin(pi*n) is 0, and cos(pi*n) is alternating 1,-1.

like image 150
mtrw Avatar answered Oct 01 '22 21:10

mtrw