#! /usr/local/bin/perl # (C) Copyright 2007 Donald R. Woods; permission granted to use and # redistribute provided this notice is retained. use strict "vars"; sub Usage { die <<"END"; Usage: eqaudio [inputfile] (if none specified, read standard input) Convert an AT file to a list of unnumbered lines each specifying a sound and the corresponding pattern, or, if given such a file as input, convert it back to a file suitable for storing in EQ\'s userdata folder. END } &Usage unless @ARGV < 2 && $ARGV[0] ne '-h'; my(%data); my $count = 0; # if undef'ed, converting from EQ, else to EQ while (<>) { chomp; /^\[Triggers\]$/ and undef $count, next; if (defined $count) { die "Malformatted file: $_\n" unless /^(\w+)\s+(.*)$/; print "[Triggers]\n" if $count == 0; print "Pattern$count=$2\nSound$count=$1\n"; $count++; } else { die "Malformatted file: $_\n" unless /^(\w+)=(.*)$/; $data{$1} = $2; } } print "PatternCount=$count\n" if $count; for (0 .. ($data{PatternCount} - 1)) { # null loop if no $data{PatternCount} my $sound = $data{"Sound$_"}; my $pattern = $data{"Pattern$_"}; $sound .= "\t" if length($sound) < 8; print "$sound\t$pattern\n"; }