openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.97k stars 2.55k forks source link

ofSoundStream not working with of 0.9.3 and Windows 7/10 #5120

Closed corybarr closed 7 years ago

corybarr commented 8 years ago

Hello. I've been working on a project that needs to check a microphone for audio input. I'm unable to get ofSoundStream to fire up properly. Here are the configurations I've tried and the results for each:

Computer 1: VS 2015, oF 0.9.3, Win 7. RTApiAsio. getDeviceInfo: error: Hardward input or output is not present...

Computer 2: VS 2015, oF 0.9.3, Win 10. Same issue as the above.

Computer 3: VS 2015, 0F 0.9.3, Win 10. [warning] ofRtAudioSoundStream: stream over/underflow detected

All attempts were made on the default audioInputExample.

I'm able to read audio input data with stock apps as well as Processing.

I've found a thread where someone recompiled RTAudio with different flags, but found no official solution. I think solidifying audio on Win systems would be a big win.

Thanks.

hardmanko commented 8 years ago

The issue here may be that 1) you don't have ASIO drivers for you sound hardware (most sound hardware does not have ASIO drivers) and 2) the interface of ofSoundStream does not expose the possibility of programmatically selecting a different sound API (e.g. DirectSound, which always works, in my experience). By default, RtAudio tries to use ASIO.

I think that you can test my hypothesis by changing line 106 of ofRtAudioSoundStream.cpp from

audio = shared_ptr<RtAudio>(new RtAudio());

to

audio = shared_ptr<RtAudio>(new RtAudio(RtAudio::Api::WINDOWS_DS));

The interface issue is related to the fact that ofSoundStream is designed to work the same across all platforms, but the problem is that all platforms do not actually work the same way, so you need at least part of the interface to work in a platform-specific way to allow users to fully configure their software.

It's not just the interface of ofSoundStream that is limited: ofRtAudioSoundStream also doesn't have an option to select a sound API.

I think that a solution is to modify the interface of ofRtAudioSoundStream by adding an RtAudio::Api argument to the setup functions so that users can select an API. The default argument of for the API could be RtAudio::Api::UNSPECIFIED, which results in the current behavior unless an API is specified. This, of course, requires users to directly use ofRtAudioSoundStream rather than the general ofSoundStream, but it allows for workarounds without modifying the oF backend code. ofRtAudioSoundStream::getDeviceList() should probably also be modified to take an RtAudio::Api argument.

ofTheo commented 8 years ago

@corybarr - did this solution work for you?

@hardmanko - I think allowing people to specify the api makes sense.
Also we could default to Directsound on windows.

dielemma commented 8 years ago

FYI - I had a similar issue on Windows 10. I changed the API manually in ofRtAudioSoundStream.cpp as described above, and now it works for me :).

icq4ever commented 7 years ago

sorry. I fix comment.

in my case, change API manually as described above, still not work. but, after install ASIO4All, and setting with offline-setting(you can install optionally), works fine. so change API manually, and install ASIO4ALL might be solution.

setting with offline-setting app, check allow pull mode (WaveRT). asio4all

zackbam commented 7 years ago

@hardmanko you saved me! The EyeHarp assistive musical instrument now works even when an ASIO driver is installed with the ASIO device disconnected :)

ofTheo commented 7 years ago

Just ran into this bug and RtAudio::Api::WINDOWS_DS worked a treat. +1 to passing in RtAudio::Api::WINDOWS_DS when targeting Windows

JunNishimura commented 7 years ago

Thanks guys, I had a same problem but now it's solved

rafadiniz commented 5 years ago

I managed to solve this problem in version 0.9.8, as indicated by hardmanko, but in version 0.10 I could not.

Can someone help me?

arturoc commented 5 years ago

since 0.10 you can choose the api through OF calls so there's no need for this patch, you can use ofSoundStreamSettings to select the api and then setup the sound stream object

rafadiniz commented 5 years ago

In line 32 of the ofRtAudioSoundStream.cpp I put:

return RtAudio :: Api :: WINDOWS_DS;

The error message is gone. And when I close the application, the PC sound continues to run without the need to turn the audio interface (PreSonus) on and off. : )

fcor commented 3 years ago

In case someone is looking for a solution here, I fixed it adding the API to ofSoundStreamSettings:

settings.setApi(ofSoundDevice::MS_DS);