<p>I'd like to pull a stream of PCM samples from a Mac's line-in or built-in mic and do a little live analysis (the exact nature doesn't pertain to this question, but it could be an FFT every so often, or some basic statistics on the sample levels, or what have you).</p>

<p>What's a good fit for this?  Writing an AudioUnit that just passes the sound through and incidentally hands it off somewhere for analysis?  Writing a JACK-aware app and figuring out how to get it to play with the JACK server?  Ecasound?</p>

<p>This is a cheesy proof-of-concept hobby project, so simplicity of API is the driving factor (followed by reasonable choice of programming language).</p>

[{'answer_id': 37550, 'author': 'Mark Harrison', 'author_id': 116, 'author_profile': 'https://Stackoverflow.com/users/116', 'pm_score': 2, 'selected': False, 'text': '<p>Apple provides sample code for <a href="https://developer.apple.com/library/content/navigation/index.html#topic=Sample+Code&amp;section=Resource+Types" rel="nofollow noreferrer">reading and writing audio data</a>. Additionally there is a lot of good information in the <a href="http://developer.apple.com/audio/" rel="nofollow noreferrer">Audio section of the Apple Developer site</a>.</p>\n'}, {'answer_id': 37784, 'author': 'diciu', 'author_id': 2811, 'author_profile': 'https://Stackoverflow.com/users/2811', 'pm_score': 4, 'selected': True, 'text': '<p>I think <a href="http://www.portaudio.com/" rel="noreferrer">portaudio</a> is what you need.\nReading from the mike from a console app is a 10 line C file (see patests in the portaudio distrib).</p>\n'}, {'answer_id': 38543, 'author': 'Chris Hanson', 'author_id': 714, 'author_profile': 'https://Stackoverflow.com/users/714', 'pm_score': 3, 'selected': False, 'text': '<p>The principal framework for audio development in Mac OS X is Core Audio; it\'s the basis for all audio I/O.  There are layers on top of it like Audio Toolbox, Audio Queue Services, QuickTime, and QTKit that you can use if you want a simplified API for common tasks.</p>\n\n<p>To just pull a stream of samples, you\'d probably want to use <a href="http://developer.apple.com/documentation/MusicAudio/Reference/AudioQueueReference/Reference/reference.html" rel="noreferrer" title="Audio Queue Services Reference">Audio Queue Services</a>; the <a href="http://developer.apple.com/documentation/MusicAudio/Reference/AudioQueueReference/Reference/reference.html#//apple_ref/c/func/AudioQueueNewInput" rel="noreferrer"><code>AudioQueueNewInput</code></a> function will set up recording of PCM data and pass it to a callback you supply.</p>\n\n<p>On your Mac there\'s a set of Core Audio examples in <code>/Developer/Examples/CoreAudio/SimpleSDK</code> that includes a use (AQRecord in AudioQueueTools) of the Audio Queue Services recording APIs.</p>\n'}]
['https://Stackoverflow.com/questions/37529', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3462/']