— command line audio on OSX

Since there is no equivilent to /dev/dsp or /dev/audio on OSX, you need to install an alternative like sox.

Install sox by either downloading the OSX binary from http://sox.sourceforge.net/ or install homebrew, and then install sox with brew install sox

examples

cat audio from /dev/urandom/ :

cat /dev/urandom | sox -traw -r44100 -b16 -u - -tcoreaudio

new file test.c

# test.c
main(t) {
  for( t = 0;;t++)
    putchar( t * ((( t >> 12 ) | (t >> 8)) & (63& (t >> 4 ))));
}

run

gcc test.c -o test
./test | sox -traw -r8000 -b8 -u - -tcoreaudio

references