In JuceDemo project, for audio demo, there is a tab for playback and another tab for recording. If I want to do the playback and recording at the same time, each runs within its own thread, how to do that? Can I use two AudioDeviceManager instances, one for the playback, and the other for the recording?
Here is the code piece I can think of:
AudioDeviceManager dm1; AudioDeviceManager dm2; dm1.initialise (2, 0, 0, true, String::empty, 0); // for recording dm2.initialise (0, 2, 0, true, String::empty, 0); // for playback // start thread 1 and do the following dm1.addAudioCallback (&audioRecorder); // start thread 2 and do the following dm2.addAudioCallback (&audioSourcePlayer);
Will it work? Or there is a better way to implement it than the above hack?