#!/bin/bash
#
#	mod2ogg
#	written by Jan Engelhardt, 2004-2007
#
#	This program is free software; you can redistribute it and/or
#	modify it under the terms of the WTF Public License version 2 or
#	(at your option) any later version.
#
#	MP3 players still lack MOD/XM/IT/MID/etc. support,
#	but at least an OGG player was affordable.
#

usage()
{
	echo "Usage:   mod2ogg [-qQUALITY] inputfile[...]";
	echo "Example: mod2ogg -q6 this.it";
	exit 1;
}

qual="-q2";
if [ "${1:0:2}" == "-q" ]; then
	qual="$1";
	shift;
fi;

if [ -z "$1" ]; then
	usage;
fi;

for i in "$@"; do
	timidity -Ow1sl -idt "$i" -o- | oggenc "$qual" - -o "$i.ogg";
done;
