#! /bin/sh
# Cleanup Bass & Chords -- <CR> for yes, "n" for no
echo -n "Length of count in: "; read X
if [ "$X" -gt 0 ]; then
	COUNTIN="(countin -b$X | bars -f$X)"
else
	COUNTIN="cat"
fi
for j in 1 2 3 4; do
	echo -n "Do chord group $j? "; read X
	if [ "$X" = "n" ]; then continue; fi
	for i in vamp I-IV I-V I-VI I-II end tiny; do
		echo -n "cleanup $i.$j? "; read X
		if [ "$X" = "n" ]; then continue; fi
		if [ -s $i.$j ]; then cp $i.$j /tmp; fi
		cp $i.$j x
		if [ $i = vamp -o $i = end ]; then BARS=2
		else BARS=1; fi
		eval $COUNTIN <x | bars -h$BARS | chmap 1=1-16 | mpuclean -L >xx
		bars x xx
		echo -n "Original in x, cleaned in xx; "
		echo -n "copy xx into $i.$j? "; read X
		if [ "$X" != "n" ]; then
			bars -h$BARS <xx | mpuclean -L >$i.$j
		fi
# need to check footswitch...
	done
done
