Synchronizing capture and playback audio?


#1

Hi everybody,

I’m a newbie, I’ve just known JUCE for a few days. I’ve been working in AEC project, my problem is synchronization between capture and playback audio. I read a brief description of AudioIODevice class reference and know that, it could make synchronization between in and out channel. But i didn’t find any tips to do this. does anyone have a sample code to perform this task. I searched in …\juce\extras\juce demo\src\demos\AudioDemo.cpp but i did’nt find.

Thanks


#2

U can use the AudioIODeviceCallBack class for redirecting the incoming sample to output channels.
u just need to copy the inputChannelData to the outputChannelData array. ur input will be ur output.


#3

[quote=“Godwin”]U can use the AudioIODeviceCallBack class for redirecting the incoming sample to output channels.
u just need to copy the inputChannelData to the outputChannelData array. ur input will be ur output.[/quote]

Thanks for answer.
I’ve just created a CSoundCapture and I implement it follow:

[i]void CSoundCapture::Init()
{

manager.initialise(1,1,0,true);

AudioIODevice* pDevice=manager.getCurrentAudioDevice();
pDevice->open(BitArray(3),BitArray(3),16000,pDevice->getDefaultBufferSize());
pDevice->start(this);
manager.addAudioCallback(this);

}

void CSoundCapture::audioDeviceIOCallback(const float** inputChannelData, int totalNumInputChannels,
float** outputChannelData, int totalNumOutputChannels, int numSamples)
{
TRACE(“audioDeviceIOCallback Invoked \n”);

}
void CSoundCapture::audioDeviceAboutToStart(AudioIODevice* device)
{
TRACE(“audioDeviceAboutToStart Invoked \n”);
}
void CSoundCapture::audioDeviceStopped()
{
TRACE(“stop\n”);
}[/i]

CSoundCapture class is inherit from AudioDeviceIOCallBack class

the function audioDeviceIOCallback isn’t invoke. the function audioDeviceAboutToStart is auto invoke, so do I have to call manually audioDeviceIOCallback inside this? and what would i have to do to pass the params of audioDeviceIOCallback?


#4

No, no, no! If you’re using an audiodevicemanager, then you mustn’t start or mess around with its AudioDevice directly - let the manager take care of that. Just initialising it and adding your object as a callback should be enough.