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?
}
}
}];