WIN10, VS2019, OF11.2
I’m interested in writing an app that responds to whatever audio is playing through the soundcard. I’ve been trying to get the audioInputExample to work, but so far, no luck.
I’ve been trying to debug, and have searched and tried a few examples, but still no luck. What seems to happen is when the application runs, it takes control of the device, so if, say, SPOTIFY was playing audio when it runs, SPOTIFY stops playing, and no audio is received by the application. If the application is running, SPOTIFY won’t play, and no other applications that play audio will play because the device is in use.
From experience with proce55ing, I had some trouble initially, but the resolution was to set the STEREO MIX to be the default recording device I believe. I tried this too, but doesn’t help.
Anyone run into this before? Anything I can try?
audioInputExample takes the stream that your soundcard is using for input. This is what you experienced with processing already: if your soundcard recording device is set to Microphone for example, the sounds from Spotify are not reaching your App - because soundcard is listening to Microhone. If you set “recording” to “Stereo Mix”, they do. Or rather they should…
Your problem seems to be of another nature. I just tried at my place (OF 0.11.1, Rest the same) and it works as expected. I tried a youtube video and it is working.
So it could be Spotify using some trick to prevent you from recording. But you said you tried with other sound-playing Apps too? Then quite probably it is a Problem in (the configuration of) your soundcard?
As a matter of fact: Your Apps should not stop playing audio if audioInputExample is started.
hope you can solve it.
have a good day!
Thanks for your reply!
SPOTIFY was just an example, it’s all apps playing audio. When I run the example in DEBUG, soundStream.printDeviceList(); causes audio to drop out momentarily, then auto devices = soundStream.getDeviceList(); causes audio to drop out momentarily, and then soundStream.setup(settings); causes audio to stop and not come back - any apps playing audio stop playing audio and and report a ‘problem with your device’ - you have to exit the example to get audio back.
Stepping into the debugger, into:
bool ofRtAudioSoundStream::setup(const ofSoundStreamSettings & settings_)
when it calls:
audio->openStream((settings.numOutputChannels > 0) ? &outputParameters : nullptr, (settings.numInputChannels > 0) ? &inputParameters : nullptr, RTAUDIO_FLOAT32,
settings.sampleRate, &bufferSize, &rtAudioCallback, this, &options);
I have STEREO MIX set as default recording device and mic is disabled.
I notice in the example that the number of output channels is set to 0, I’m not sure how you get audio out if there are no output channels? If I change that to 2, the application crashes while trying to calculate root mean square volume.
I got it working - I’m not sure how the example works for anyone else, i had to do it by explicitly choosing the MS_WASAPI API, and selecting the 3rd device, which is the stereo mix.
The code to do this in the example if out of date and does not work, so you need to use these calls instead:
auto devices = soundStream.getDeviceList(ofSoundDevice::Api::MS_WASAPI);
Hi, if I recall correctly, audio in debug mode on windows does not work nicely. try switching to release mode.
As you mention, also forcing which API to use and the device number helps a lot.
I tried Release when i was debugging, didn’t work - selecting the API explicitly works really nicely though.