#!/bin/sh duration=300 magic=/usr/share/misc/magic-mm dsp_progs=$(cat ~mats/.dsprc) kill_mmwrapper() { local pst pids p sig pst=$(ps xao pid,command | \ egrep '^ *[0-9]+ /bin/sh .*(mmwrapper|play_sid|play_ym)') if [ -n "$pst" ]; then pids=$(echo "$pst" | sed -E 's/^ *([0-9]+).*$/\1/') for p in $pids; do if [ $p -ne $$ ]; then kill $p; fi done fi for p in $dsp_progs; do sig=; if [ "$p" = "mplayer" ]; then sig="-9"; fi killall $sig $p done nawk 'BEGIN { while(("chkdsp /dev/dsp" | getline) > 0) { if ($0 == 1) break } }' mixer pcm 76 } do_file() { local ts t ns s ts="$(file -m $magic "$1")"; t="${ts#*: }" case "$t" in PlaySID\ *) ns=$(echo "$t" | sed -E 's/^.+, (single|[0-9]+) songs?, .+$/\1/') if [ "$ns" = "single" ]; then ns=1; fi s=1 while [ $s -le $ns ]; do sidplay -f48000 -16 -o$s -t$duration "$1" s=$(($s + 1)) done esac } trap '' 1 exec >/dev/null 2>&1 kill_mmwrapper if [ -d "$1" ]; then IFS=" " for f in $(find "$1" -type f); do do_file "$f" done else do_file "$1" fi .