#!/usr/bin/perl

$inputfilename="equalizers.xml";
$outputfilename="WinampEqualizer10Bands.prs";

open (INPUT, "$inputfilename")
	|| die "Can't open $inputfilename: $!";

open (OUTPUT, ">$outputfilename")
        || die "Can't open $outputfilename: $!";

print (OUTPUT <<EOF);
[_presets_]
version=0.10
element-name=GstIirEqualizer10Bands

EOF

$preamp=0.0;
while (<INPUT>) {
    if (m/<equalizer name="(.*)">/) {
        print (OUTPUT "[$1]\n");
    } elsif (m/<\/equalizer>/) {
        print (OUTPUT "\n");
    } elsif (m/<preamp>(.*)<\/preamp>/) {
        $preamp=10.0**($1/20.0);
        #print (OUTPUT "preamp=$preamp\n");
    } elsif (m/<band num="(.)">(.*)<\/band>/) {
        print (OUTPUT "band$1=$2\n");
    }
}
close (INPUT);

