Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Command line audio players for Mac OS X

For information on how to install MacPorts see here and here.
# qtplay & mpg123

export PATH="/opt/local/bin:/opt/local/lib:/opt/local/include:/opt/local/man:${PATH}"
alias port=/opt/local/bin/port

port list | grep -i audio

port info qtplay 
port info mpg123

/usr/bin/sudo port -c install qtplay
/usr/bin/sudo port -c install mpg123

mpg123 file.MP3

qtplay file.MP3
qtplay 'http://file.mp3'
qtplay 'http://file.mov'     # http://www.apple.com/trailers/


#-----------------------------------------


# play, http://www.hieper.nl/html/play.html

export PATH="/usr/local/bin:${PATH}"

# create /usr/local/bin
/usr/bin/sudo /bin/mkdir -p /usr/local/bin
/usr/bin/sudo /usr/sbin/chown root:wheel /usr/local /usr/local/bin
/usr/bin/sudo /bin/chmod 0755 /usr/local /usr/local/bin

cd ~/Desktop
curl -L -O http://www.hieper.nl/downloads/play.dmg
hdiutil mount ~/Desktop/play.dmg
open -a Safari '/Volumes/play 1.3/readme.html'
/usr/bin/sudo /bin/cp -i '/Volumes/play 1.3/play' /usr/local/bin
ls -l /usr/local/bin/play
hdiutil unmount '/Volumes/play 1.3'

play ~/Music/Winterreise/Gute\ Nacht.mp3

# listen to the first 10 seconds of each Schubert song on your computer
mdfind "kMDItemComposer == Schubert" | play -vt 10


#-------------------------------------------------------------


# afplay
# compile & install afplay and related command line audio tools (Mac OS X 10.4.11)
# requires Xcode, http://developer.apple.com/tools/xcode/index.html

ls -1 /usr/bin/af*     # Mac OS X 10.5
ls -1 /usr/bin/au* 

# Mac OS X 10.4
open /Developer/Examples/CoreAudio/Services/AudioFileTools/AudioFileTools.xcodeproj
# ... then just press "Build"

ls -l /Developer/Examples/CoreAudio/Services/AudioFileTools/build/Development-Panther/* | nl
ls -1 /Developer/Examples/CoreAudio/Services/AudioFileTools/build/Development-Panther/* | nl


#/usr/bin/find /Developer/Examples/CoreAudio/Services/AudioFileTools/build/Development-Panther -mindepth 1 | \
#     /usr/bin/xargs -I '{}' /usr/bin/sudo /bin/cp -i '{}' /usr/local/bin

/bin/ls -1 /Developer/Examples/CoreAudio/Services/AudioFileTools/build/Development-Panther/* | \
     /usr/bin/xargs -I '{}' /usr/bin/sudo /bin/cp -i '{}' /usr/local/bin

ls -l /usr/local/bin/af*
ls -l /usr/local/bin/au*

afconvert
afinfo
afinterleave
afplay
afrecord
auprocess
auprofile


# background music
# cf. http://codesnippets.joyent.com/posts/show/1508
/usr/bin/screen -d -m afplay "/path/to/file.MP3"

kill -HUP $$
kill -HUP $PPID
killall -HUP Terminal


apropos audio
apropos sound

# set global Mac OS X sound output volume
# see http://osxutils.sourceforge.net
man setvolume   
setvolume 50

DAAP tunneling / remote iTunes Music Share

// requirements
// * server running mt-daapd/Firefly (alternative server for iTunes music sharing)
// * tunneleling & port-forwading via ssh
// * local bonjour/zeroconf broadcasting using Apple's mDNSProxyResponder
// based on info from <http://wiki.mt-daapd.org/wiki/SSH_Tunnel>
// for more: see Music Blackhole <http://tramchase.com/projects/blackhole>
// Jamie Wilkinson <http://tramchase.com>


ssh USER@SERVERNAME -N -f -L 3690:SERVERNAME:3689 && mDNSProxyResponderPosix 127.0.0.1 musicserver "My remote music server" _daap._tcp. 3689 &

Make iTunes arrows point to your own music, not the iTS

defaults write com.apple.iTunes invertStoreLinks -bool YES


This makes those little right-pointing arrows in iTunes point to your library, not the iTunes Store. If you want the iTunes Store, Option-click instead.