FILE="$1"
CHAN="$2"
if [ "$FILE" = "" ]; then
	echo -n "file to transcribe: "; read FILE
fi
if [ "$CHAN" = "" ]; then
	echo -n "channel(s) to transcribe: <all> "; read CHAN
fi
echo "00 90 0 40 1 90 0 0 77 f9" | rpt 4 | axtobb >/tmp/$$b
LEN=`bars -q $FILE`
echo "Piece length is $LEN"
rpt $LEN </tmp/$$b >/tmp/$$c
cat /tmp/$$b >>/tmp/$$c
echo "00 90 3c 40 1 3c 0 77 f9 00 90 0 40 1 0 0" | rpt 4 | axtobb >>/tmp/$$c
echo -n "Tap sample? <yes> "; read X
if [ "$X" != "n" ]; then
	echo "00 90 0 40 1 90 0 0 77 f9" | axtobb | play
fi
for C in $CHAN; do
	if [ "$CHAN" = "" -o "$CHAN" = "all" ]; then
		cat $FILE >/tmp/$$a
	else
		chmap $C=$C <$FILE >/tmp/$$a
	fi
	echo -n "Hit return when ready for channel $C: "; read X
	merge /tmp/$$a /tmp/$$c | play
done
echo "All done"
