开发者

How to Spectrum-inverse a sampled audio signal

I am looking for a simple (pseudo)code that spectrum-inverse 开发者_如何学Pythona sampled audio signal. Ideally C++

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


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.


In order to get something that has the same type of temporal structure as the original, you need to

  • Create a spectrogram (with some window size)
  • Pick some upper and lower frequency bounds that you'll flip
  • Flip the spectogram's intensities within those bounds
  • Resynthesize a sound signal consistent with those frequencies

Since it's an audio signal, it doesn't much matter that the phases will be all messed up. You can't generally hear them anyway. Except for the flipping part, ARSS does the spectrogram creation and sound resynthesis.

Otherwise, you can just take a FFT, invert the amplitudes of the components, and take the inverse FFT. But that will be essentially nonsensical, as it will completely scramble the temporal structure of the sound as well as the frequency structure.


it does not make much sense to use a cosine. for a digital signal it is not neccessary to run a real ringmod here, at nyquist a consine is a square anyway.

so you would just multiply every other sample by *-1 and you are done.

no latency, no aliasing, no nothing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜