Which /dev/... (devices) are the microphone and speaker in Mac OS X?
Asked Answered
S

2

11

I have a MacBook Alluminium and I want to capture the microphone in a RAW format and output a RAW audio through the speakers, in a standard way, i.e., using the terminal with standard Unix commands and using the standard /dev/??? devices.

So, the question/s:

  • Which devices are the microphone and speakers? Those both should start with /dev/...

  • Are they different if they are built-in or external? Which ones? (Also they have to start with /dev/...)

If you know also the unix commands to print the microphone input and to write the output for speakers that would be extra points! :) (I want to capture it from mic, modify it -I got it-, and send it modified to speakers)

If you know also the Assembly instructions for OSX that would be the perfection! But the main questions are which are in the bulleted list.

Thanks!

Sunset answered 14/2, 2013 at 2:50 Comment(5)
Why do you want to do this with raw /dev devices, why not use Core Audio? or one of the higher-level APIs.Bartie
Because I want it to be easily transformed into a linux compilable code, keeping it fast as I want to use AssemblySunset
You do not need to use assembly to write fast code. Hell, you don't even need fast code to do audio processing. You could probably write your code in Python and it'd be more than fast enough.Alver
Thanks for the comment, but I have to do it for the University using SIMD instructions. And yes, for some kind of audio processing it's better to use Assembly -try to implement by yourself a FFT in python for a real time audio processing-. It depends on what you want to do. Thank you anyway!Sunset
The vast majority of commercial audio software is built in C++, with a few performance sensitive bits hand-coded in assembler. Compilers are actually pretty good at using SIMD instructions with a little bit of encouragement.Assuage
B
8

As @duskwuff says, you probably won't have any joy trying to access sound devices using /dev devices on OS X.

If, as you say in your comment above, your goal is cross-platform portability then perhaps PortAudio might be a solution.

From their homepage:

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.

On OS X I believe they use Core Audio and on Linux they use OSS/ALSA.

Bartie answered 14/2, 2013 at 4:18 Comment(2)
Perfect! Even though I was looking something like sox, PortAudio is what I need as I need something fast and easy to use with multiple platforms. Thanks! :)Sunset
It's worth mentioning that ALSA only provides /dev nodes for compatibility with OSS. Virtual devices are not the way modern or high performance audio APIs work.Cornstalk
A
11

None of them. Not all devices have /dev nodes on Mac OS X, and audio devices are not among them. There is no way I'm aware of to access audio devices using only "standard" terminal commands. sox can be used if you install it, but it is not shipped with Mac OS X.

The primary supported API to access audio devices on Mac OS X is Core Audio. Third-party libraries, such as libao, are also available which can expose a simpler, platform-independent interface to Core Audio.

Alver answered 14/2, 2013 at 3:14 Comment(3)
I downloaded and installed SoX and have being playing with it, recording and playing a sound. Anyway, I couldn't do it as a stream of: input => file/socket => output, How can I do that?Sunset
Simple example: sox -d -p | sox -p -d. Read the documentation (man sox, or sox -h) for details.Alver
Well, thank you so much! That command in addition with --buffer worked very well! Anyway, PortAudio works better with small buffers like 64 frames per buffer. Thanks!Sunset
B
8

As @duskwuff says, you probably won't have any joy trying to access sound devices using /dev devices on OS X.

If, as you say in your comment above, your goal is cross-platform portability then perhaps PortAudio might be a solution.

From their homepage:

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.

On OS X I believe they use Core Audio and on Linux they use OSS/ALSA.

Bartie answered 14/2, 2013 at 4:18 Comment(2)
Perfect! Even though I was looking something like sox, PortAudio is what I need as I need something fast and easy to use with multiple platforms. Thanks! :)Sunset
It's worth mentioning that ALSA only provides /dev nodes for compatibility with OSS. Virtual devices are not the way modern or high performance audio APIs work.Cornstalk

© 2022 - 2024 — McMap. All rights reserved.