Code sample for capturing audio from a Mac in Cocoa and saving to file?

后端 未结 2 1410
故里飘歌
故里飘歌 2020-12-07 21:34

I\'m due to work on a small application that captures audio from the Mac\'s Audio Queue and needs to save it to disk in some reasonable audio format.

Does anyone hav

2条回答
  •  失恋的感觉
    2020-12-07 22:09

    Working with audio in Mac OS X involves interfacing with Core Audio. For a quick overview, take a look at the Core Audio Overview.

    You will need to interface with the AUHAL to perform input and output; a technical note exists detailing the steps required to do so. This code seems to usually be written in C++, as that is the procedure taken in the SimplePlayThru demo.

    This doesn't cover the actual steps required to capture that audio input. However, these links should provide you with enough sample code to begin interfacing with your input device. I'll post more links in this answer if I happen across them.


    Take a look at /Developer/Example/CoreAudio/Services/AudioFileTools. Specifically, look at afrecord.cpp. Admittedly, this is not Cocoa per se; Cocoa itself doesn't seem to have any specific capabilities for recording. If you'll want to interface with the C++ file there, you'll likely need to write some Objective C++ like in SimplePlayThru.

提交回复
热议问题