#!/usr/pkg/bin/bash
# db file must be text: songname transpose drop, e.g.: shout 3 3
# transposes up 3 half-steps, drops channel 3 (melody track on Roland midis)
# best to have both a .mid and .html file for song
# symlink this script to 'practice' to keep melody track in
music=$HOME/My\ Documents/My\ Music
extension=.mid
program=`echo $0 | awk -F / '{print $NF}'`
for file in $@; do
 exec <$file
 while read song transpose drop; do
  if [ "$drop" ]; then drop=" -d $drop"; fi
  if [ "$program" = "practice" ]; then drop=; fi # don't drop if practicing
  if [ "$transpose" ]; then transpose="-t $transpose"; fi
  if [ "$program" != "wpractice" -a -f "$music/$song.html" ]; then
   lynx --dump "$music/$song.html" | less &
  fi
  if [ "$program" != "wpractice" ]; then
   midiplay $transpose $drop "$music/$song.mid" || exit
  else
   ( cd "$music" && winamp "$song.mid" & )
  fi
 done
done
