Mute but continue sampling

I have a basic audio playback setup (play a wave file, more or less) and I'd like to be able to mute the output device but still have it continue sampling the source file, so when the user unmutes it will start playing where it is currently sampling from (not from where it was muted).  How best can I accomplish this?

Here's basic init code...

this->audioDeviceManager = new AudioDeviceManager();
this->audioDeviceManager->initialiseWithDefaultDevices (0, 2);

this->myAudioSource = new MyAudioSource(computedQueueSize);
this->resampledSource = new ResamplingAudioSource(this->myAudioSource, false);
this->resampledSource->setResamplingRatio(sourceSampleingRate / outputSourceSampleingRate);

this->audioSourcePlayer.setSource (this->resampledSource);

// give the device manager our player

Does audioDeviceManager->getCurrentAudioDevice()->stop() accomplish what I need?  The docs read like it will stop sampling.  Or do I need to implement a "save the current output levels" , "set levels to 0" method to accomplish my 'mute/unmute' implementation?



Calling stop on the device will cause the audio processing to stop.  You probably want to manipulate the audio buffer to set the gain level to 0 for mute and 1 when unmuted.  In your "MyAudioSource"  through the AudioSourceChannelInfo you can access the AudioSampleBuffer which has methods to manage the gain levels.  It may be worth looking at the applyGainRamp methods which helps give you a smooth mute.  A straight set from 1 to 0 (or 0 to 1) can cause glitch/pop sounds.