WASAPI sampling rate problem

Hey there,
is it somehow possible to set the sample rate of WASAPI audio device?
When the input and output sample rate aren’t the same, then the audio device doesn’t get initialized and therefore the application crashes!
Those sampling rates are configured from the windows system UI and can differ (e.g. 44kHz input and 48kHz output -> crash).
On the other operating systems and apis (e.g. ASIO) this can be done.

We cannot force our users to install ASIO, so it would also be nice if someone knows how to package it with an application :slight_smile:
thanks in advance

1 Like

Unfortunately this is a drawback of WASAPI in shared mode as it doesn’t do any built-in resampling so the input and output device sample rates must be the same. JUCE does some wrangling internally to try and match the two, but if there are no compatible sample rates available then the device can’t be opened.

This shouldn’t cause any crashes though, the audio device just fails to open with a helpful error message telling you what has going wrong. Are you experiencing a crash in the JUCE code or in your app’s code?

If AudioAppComponent is used, it just jasserts in setAudioChannels if the AudioDeviceManager fails to open the device. The error string is local in the method and can’t be retrieved from outside the method.


True, I was thinking in terms of a more complex application where the OP had control over the audio devices and device manager. I suppose a solution for the AudioAppComponent case would be to store any error messages when opening devices and have a getLastError() message or something similar.

Apparently it seems like it will do it (as of Win8) if you call the right API chants. See Enabling Windows Audio's SRC