How to Spectrum-Invert Sampled Audio

I am looking for a simple (pseudo) code that inverts the spectrum of an audio signal. Ideal C ++

The code must support different sampling frequencies (16/32 / 48KHz).

+6
algorithm audio signal-processing
source share
3 answers

Mixing the signal on Fs/2 will lead to the exchange of high frequencies and low frequencies - think about turning the spectrum around the unit circle by half a revolution. You can achieve this rotation by multiplying each other by -1.

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

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

This is easily simplified because sin(pi*n) is 0, and cos(pi*n) alternates with 1, -1.

+6
source share

To get what has the same type of temporal structure as the original, you need

  • Create a spectrogram (with some window size)
  • Select the upper and lower bounds of the frequencies that you will invert.
  • Reflect spectrogram intensities within these boundaries
  • Resynthesize the audio signal corresponding to these frequencies.

Since this is an audio signal, it doesn’t matter much that the phases will be corrupted. You cannot hear them at all. With the exception of the inverted portion, ARSS performs spectrogram creation and sound resynthesis.

Otherwise, you can simply take the FFT, invert the amplitudes of the components, and take the inverse FFT. But this will be essentially meaningless, since it will completely destroy the temporal structure of sound, as well as the frequency structure.

+1
source share

it makes no sense to use cosine. for a digital signal, there is no need to run a real ring link here, with the nyquist being a square.

so that you simply multiply each other pattern by * -1 and you are done.

no latency, no smoothing, nothing.

0
source share

All Articles