0

For active noise cancellation purposes, how would I generate an antiphase signal using Novocaine? That is to say, within a NovocaineOutputBlock, how to generate an output that is 180 degrees out of phase with the input?

Here's my code so far:

__weak AppDelegate * wself = self;

self.ringBuffer = new RingBuffer(32768, 2);
self.audioManager = [Novocaine audioManager];

[self.audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
{
    wself.ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
}];

[self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
{
    wself.ringBuffer->FetchInterleavedData(data, numFrames, numChannels);

    for (int i=0; i < numFrames; ++i)
    {
        for (int iChannel = 0; iChannel < numChannels; ++iChannel)
        {
            // Within here do noise cancellation. How?
        }
    }
}];
Marco
  • 6,692
  • 2
  • 27
  • 38

1 Answers1

-1

I have been wondering the same thing. My idea was to use something like this:

data[i*numChannels + iChannel] *= -1;

EDIT This piece of code could potentially be used to invert the phase (it might not even work). However, there is typically more to active noise cancellation than simply inverting the phase, considering the latency of the iPhone itself.

Miles
  • 175
  • 1
  • 9