问题
As part of a university project I have to do some signal processing and would like to output the results using the PC sound card. The software has to be written in C and needs to work with Windows (preferably 7 and XP).
I have found code examples for outputting .wav and similar files, but I am interested in continuously outputting data rather than outputting from files. It is likely that the data for output will be presented as an array although some sound APIs seem to have their own ways of dealing with buffers.
Any suggestions would be great, as would code examples or even the best API. I have looked at DirectSound and OpenAL but am still unsure how to get started.
回答1:
PortAudio is a C library that should suit your needs. There is a tutorial to get you started.
PortAudio is a free, cross-platform, open-source, audio I/O library. It lets you write simple audio programs in 'C' or C++ that will compile and run on many platforms including Windows, Macintosh OS X, and Unix (OSS/ALSA). It is intended to promote the exchange of audio software between developers on different platforms. Many applications use PortAudio for Audio I/O.
PortAudio provides a very simple API for recording and/or playing sound using a simple callback function or a blocking read/write interface. Example programs are included that play sine waves, process audio input (guitar fuzz), record and playback audio, list available audio devices, etc.
回答2:
https://github.com/rdp/directshow-demo-audio-input-open-source might help, if you want to use directshow.
来源:https://stackoverflow.com/questions/6144543/streaming-data-to-sound-card-using-c-on-windows