简体   繁体   中英

Mac OS X sound output

Are there any examples for how to output a raw sound buffer on Mac OS X?
Something like pa_simple_write() for pulseaudio or waveOutWrite() from WINAPI.

You need to create an AudioQueue .

Next you need to allocate a buffer . Once allocated, you then fill it with data and enqueue it . Finally you call AudioQueueStart . You can then immediately call AudioQueueStop passing false as the last parameter.

The above won't work very well, though, if you need to play multiple sounds simultaneously. If you wish to do that, AFAIK, you'll need a more complex setup where you mix audio into a buffer. That will get complicated quickly, though ...

Easiest way I've run into is to use libao . Conveniently, it's also cross-platform.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM