News for hackers. Stuff that matters.
Re:/dev/audio by pavel_lishin on Tuesday November 08, 2011 @05:33PM (#3213177)
Alas, OS X doesn't seem to support anything like this.
Re:/dev/audio by ajross on Tuesday November 08, 2011 @06:00PM (#3213312)
Neither does modern Linux, sadly. The older SunOS-style audio devices still exist in the kernel as an emulation, but aren't loaded by default (and tend to have weird behavior vs. other parts of your distro's audio stack). The ALSA framework is the modern equivalent. It's much more featureful, but its device API is frustratingly opaque. So much so that the only "supported" interface to the driver is the libasound userspace library. This, too, is low level and opaque. So you're really supposed to use the pulseaudio middleware to actually play and mix your audio stream. And even then, the pulse API is basically PCM-only, and your stream is probably sourced from something encoded. So you really want to be using gstreamer to generate your stream and take advantage of existing codec plugins (and hardware acceleration, etc...). And even then gstreamer is opaque, so all the toolkits have wrapper APIs.

Sigh. The days of being able to spit sounds to a char device are basically over. We have more powerful software now with far more capability. And that kind of sucks, sometimes.

Re:/dev/audio by njs12345 on Tuesday November 08, 2011 @06:12PM (#3213359)
Try using `padsp tee /dev/audio` >& /dev/null

For example: sudo cat /dev/mem | `padsp tee /dev/audio` >& /dev/null

Re:/dev/audio by ajross on Tuesday November 08, 2011 @06:29PM (#3213411)
Yes yes. The existence of that silliness is kind of my point. There's nothing "wrong" with Linux audio from a technical/feature standpoint. But the aesthetics are a frothing mess. It's not a clean design.

The /dev/audio device on SunOS 4.1 was a clean design (albeit one that solved a much simpler problem). That sanity wasn't preserved in the march to modernity, and it sucks.

Re:/dev/audio by njs12345 on Tuesday November 08, 2011 @06:55PM (#3213484)
The design is pretty similar to how every other modern OS does it, I think - what would you change if you had the choice?

I mean, it's not as clean as things were, but we've come a long way since then in terms of features so obviously simplicity is going to suffer. Worth the trade off, in my opinion :)

Re:/dev/audio by burgerbrain on Tuesday November 08, 2011 @10:45PM (#3214160)
You can also use pacat

Example: `cat /dev/urandom | pacat`

Re:/dev/audio by saucerful on Tuesday November 08, 2011 @08:08PM (#3213745)
I followed along the examples by piping into the command line ALSA player 'aplay', which is I think included in all ALSA installs.
Re:/dev/audio by bingaling on Tuesday November 08, 2011 @06:13PM (#3213361)
It can be done on OS X with sox:

    cat /dev/urandom | sox -traw -r44100 -b16 -u - -tcoreaudio
Re:/dev/audio by semanticist on Tuesday November 08, 2011 @07:12PM (#3213560)
sox isn't part of core Mac OS X, and the homebrew package appears to be broken at the moment.

I don't think there's a built-in method to play raw audio like this.

Re:/dev/audio by pavel_lishin on Tuesday November 08, 2011 @09:57PM (#3214026)

    brew update
Fixed all my ills.
Re:/dev/audio by nknight on Tuesday November 08, 2011 @07:20PM (#3213590)
Conveniently, the sox project on sourceforge has Mac OS X binaries available.

http://sox.sourceforge.net/

Re:/dev/audio by pavel_lishin on Tuesday November 08, 2011 @06:27PM (#3213403)
Excellent, thanks!
Re:/dev/audio by aidos on Tuesday November 08, 2011 @06:56PM (#3213494)
Actually, while we're on the topic(ish), how does one do it back the other way? Ie, stream from audio input to a file (I was looking into it earlier today). Best I could find, you had to install some wrapper drivers or something.
Re:/dev/audio by aranazo on Wednesday November 09, 2011 @07:18AM (#3215197)
If you run pulseaudio you can use parec. It's fiddly but there is an example script here http://www.outflux.net/blog/archives/2009/04/19/recording-fr...