Apple - Alternative to APLAY for Mac OS X bash

Here is the same program, as a perl one-liner, which works (tested) on Mac, Linux, and Windows

perl -e 'for($i=0;;$i++){
    print pack("n", ((($i*($i>>8|$i>>9)&46&$i>>8))^($i&$i>>13|$i>>6))); 
}' | ./play -c 1 -b 8 -e unsigned -t raw -r 8k -

the "./play" command is the "sox" utility already mentioned in this article. 


I believe the sox utility stands in for aplay.



I know that this topic is old, but I've find a recent working solution. SOX doesn't support input from stdout anymore so now a working alternative is mplayer. You'll need to install it using Hombrew.sh with brew install mplayer.

You can then replace aplay by: mplayer -cache 1024 -quiet -rawaudio samplesize=1:channels=1:rate=8000 -demuxer rawaudio -

Just be sure to change rate=8000 with your custom frequency.

You can create an alias in ~/.bashrc for aplay to pipe your PCM chiptune in like this:

alias aplay="mplayer -cache 1024 -quiet -rawaudio samplesize=1:channels=1:rate=8000 -demuxer rawaudio -"

Hope this helped, tested on macOs Sierra 10.12.5 today.

Tags:

Macos

Bash