[linux-audio-user] Small shell script
Emiliano Grilli
emillo at libero.it
Tue Jul 26 11:12:21 EDT 2005
Hi,
I used to play files on console with "alsaplayer -i text", to have a CLI
jack-aware player, but what was annoying is that alsaplayer doesn't do
resampling very well (e.g. if you play a 48Khz file on a 44.1Khz
soundcard). Then I started using jacklaunch with mpg123 and ogg123, but
in this case filenames with spaces did'nt work :(
So i created this little script stealing some code from the jacklaunch
script. It's tested on my DeMuDi 1.2.1 .... I hope someone can find it
useful too... I leaved alsaplayer to play .m3u as you can't know if they
contain oggs or mp3s or both... (listening to the wonderful
http://opensrc.org/radio.m3u now :))
PS: as I'm not a programmer at all, it surely contains naive errors...
any comment / suggestion / correction is highly appreciated.
Ciao
--
Emiliano Grilli
Linux user #209089
http://www.emillo.net
-------------- next part --------------
#!/bin/sh
jackcnt=`ps -e | grep -c jackd`
PREFIX=/usr
LD_PRELOAD_OLD=""
if test "$LD_PRELOAD" != ""
then
LD_PRELOAD_OLD=$LD_PRELOAD
PRELOAD=$LD_PRELOAD:$PREFIX/lib/libjackasyn.so.0
else
PRELOAD=$PREFIX/lib/libjackasyn.so.0
fi
if test -f $PREFIX/lib/libjackasyn.so.0 -a "$jackcnt" != "0"
then
export LD_PRELOAD=$PRELOAD
fi
OLDIFS=$IFS
export IFS=''
for i in $@
do
EXTENSION=`echo $i | sed -e 's/.*\.\(.*\)$/.\1/'`
if [ `pidof jackd` ]
then
case $EXTENSION in
.wav | .au | .aiff | .aif | .smp | .snd | .WAV | .Wav | .AU | .AIFF )
echo `echo $i |sed -e's/ /\\\ /g'`|xargs play ;;
.mp3 | .Mp3 | .MP3 )
echo `echo $i |sed -e's/ /\\\ /g'`|xargs mpg123 ;;
.m3u )
echo `echo $i |sed -e's/ /\\\ /g'`|xargs alsaplayer -i text ;;
.ogg | .Ogg | .OGG )
echo `echo $i |sed -e's/ /\\\ /g'`|xargs ogg123 ;;
.mid | .MID | .Mid | .midi | .MIDI )
echo `echo $i |sed -e's/ /\\\ /g'`|xargs timidity ;;
esac
else
echo "jackd not running; Exiting..." && exit
fi
done
if test "$LD_PRELOAD_OLD" != ""
then
export LD_PRELOAD=$LD_PRELOAD_OLD
else
unset LD_PRELOAD
fi
export IFS=$OLDIFS
More information about the Linux-audio-user
mailing list