Problem with ofSoundStream

hi,
i made an app that uses the onboard sound card using the direcshow drivers in windows:

ofSoundStreamSettings settings;
	settings.setApi(ofSoundDevice::Api::MS_DS);
	auto devices = soundStream.getDeviceList(ofSoundDevice::Api::MS_DS);
	settings.setInDevice(devices[4]);
	settings.setInListener(this);
	settings.sampleRate = sampleRate;
	settings.bufferSize = bufferSize;
	settings.numBuffers = 2;
	settings.numInputChannels = 2;
	settings.numOutputChannels = 0;
	soundStream.setup(settings);

the problem is that sometimes i have to run it a few times till it open, the first few times it just crashes without giving any error, and i have no idea why it may be.
i don’t have this problem with all the api, but MS_DS is one of the few that make this (and i need to use this one in this app).
any idea what may be causing the problem?

thank you

after doing some more tests, the problem seems to happen when i have input channels, if there are no inputs it always runs fine.

Could be the device being opened by other application or your main system?
Try with numBuffers with 2x of the number of enabled channels (2 * 2inputs = 4); I have seen somewhere that seems recommended.

1 Like

i’ve tried increasing the number of buffers and i still have the same problem. in all the cases the device was only been used by oF…

… Sorry, I don’t know.

But maybe you can try to apply the settings like this:
ofSoundStreamSetup(settings);
(not using soundStream.setup(settings);)

Have you tried the OF sound examples? what OF version are you using?

You can check and verify too that you are selecting an input device here: [in:2 out:0]

[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 0] Default Device [in:2 out:2] (default in) (default out)
[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 1] VoiceMeeter Input (VB-Audio VoiceMeeter VAIO) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 2] CABLE Input (VB-Audio Virtual Cable) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 3] Speakers (Realtek(R) Audio) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 4] Panasonic-TV (NVIDIA High Definition Audio) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 5] VoiceMeeter Aux Input (VB-Audio VoiceMeeter AUX VAIO) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 6] VoiceMeeter Aux Output (VB-Audio VoiceMeeter AUX VAIO) [in:2 out:0]
[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 7] VoiceMeeter Output (VB-Audio VoiceMeeter VAIO) [in:2 out:0]
[notice ] ofxSoundDevicesManager::logLine: [MS DirectShow: 8] CABLE Output (VB-Audio Virtual Cable) [in:2 out:0]
[notice ] ofxSoundDevicesManager::logLine: 

[notice ] ofxSoundDevicesManager::logLine: [MS WASAPI: 0] CABLE Input (VB-Audio Virtual Cable) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS WASAPI: 1] Speakers (Realtek(R) Audio) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS WASAPI: 2] VoiceMeeter Input (VB-Audio VoiceMeeter VAIO) [in:0 out:2] (default out)
[notice ] ofxSoundDevicesManager::logLine: [MS WASAPI: 3] Panasonic-TV (NVIDIA High Definition Audio) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS WASAPI: 4] VoiceMeeter Aux Input (VB-Audio VoiceMeeter AUX VAIO) [in:0 out:2]
[notice ] ofxSoundDevicesManager::logLine: [MS WASAPI: 5] VoiceMeeter Output (VB-Audio VoiceMeeter VAIO) [in:2 out:0]
[notice ] ofxSoundDevicesManager::logLine: [MS WASAPI: 6] CABLE Output (VB-Audio Virtual Cable) [in:2 out:0]
[notice ] ofxSoundDevicesManager::logLine: [MS WASAPI: 7] VoiceMeeter Aux Output (VB-Audio VoiceMeeter AUX VAIO) [in:2 out:0] (default in)
1 Like