based on http://sox.sourceforge.net