0

I have a buffer full of real/imaginary sample values of a signal, and would like to shift the signal in the frequency domain by multiplying a sinusoid.

I see myself with four options:

  • some IPP function (I could not find one though)
  • manually calculate the result (probably slower than IPP)
  • generate the sinusoid in a separate buffer (probably requires lots of memory)
  • generate parts of the sinusoid in a separate buffer (requires recalculating the tone buffer)

I'm wondering what would be the best approach here, and/or whether I have just missed that there is a readymade function for frequency shifting a complex signal.

Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
Simon Richter
  • 28,572
  • 1
  • 42
  • 64

1 Answers1

0

If you are going for speed, do it in the frequency domain.

FFT -> circular shift by N bins -> IFFT

I have found the ffw++ wrapper quite handy.

If you are really set on doing it in the time domain, you could use Intel's VML functions in some fashion like this:

// Create a single period of frequency offset wave
vector<complex<float> > cxWave(period);
for(int i = 0; i < period; ++i)
  cxWave = i * 2 * M_PI / period;
vcExp( period, &cxWave.at(0), &cxWave.at(0) );

// Multiply entire signal by the complex sinusoid
for(int frame=0; frame < numFrames; ++frame)
{
  vcMul( period, &input.at(frame*period), &cxWave.at(0), &cxWave.at(0) );
}

You would of course need to fill in the blanks.

Ethereal
  • 2,604
  • 1
  • 20
  • 20
  • No, that is horribly slow, and only handles multiples of the base frequency. – Simon Richter Sep 15 '12 at 18:41
  • The relative speed probably depends on the application; I have found frequency shifting using FFT to be much faster. Perhaps it is your implementation that is slow? Based on the fact the the OP's signal is complex, it would seem that the goal is not a simple low-rate vocal pitch shift. The bin resolution depends not only on the base frequency but also (and more importantly) on the FFT size. Here's a well written [overview](http://www.dspdimension.com/admin/pitch-shifting-using-the-ft/) of the concept to brush up on. – Ethereal Sep 17 '12 at 12:43