Setting sampleRate with AudioDeviceSetup


#1

Having problems setting a different sampleRate from default 44100. 

 

my code:  

    AudioDeviceManager::AudioDeviceSetup deviceSetup = AudioDeviceManager::AudioDeviceSetup();

    deviceSetup.sampleRate = 8192;

    deviceManager.initialise (2, 2, 0, true, String::empty, &deviceSetup);
    
  

    log->writeToLog(String(deviceSetup.sampleRate));

    log->writeToLog(String(deviceManager.getCurrentAudioDevice()->getCurrentSampleRate()));

Gives me 

8192

44100

 

Maybe I'm missing something here? 


#2

That's an odd looking sample rate, maybe your device doesn't support it and the code drops back to 44100.


#3

I also tried 11025 and 22050 and got similar results, however trying at 48000 (which I know my audio device supports) worked fine. I had not made the link between audio device support and sample rate. 

Is there a way to 'force' an AudioCallback to sample the audio input at a certain rate, a division of the default, for the purpose of processing incoming audio? I'm working on some pitch detection functionality and I don't need the audio to be coming in at 44100, 11025 is more than sufficient most of the time.  

Thanks