Tonality named blocks have been documented.
[ahxm.git] / gigdump2ahs.pl
blob68af773ba42df25c827e2c4c48742dbc862280b5
1 #!/usr/bin/perl
4 # gigdump2ahs.pl - Creates a .ahs instr. definition script from gigdump's output
6 # Copyright (C) 2005 Angel Ortega <angel@triptico.com>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 # http://www.triptico.com
25 $VERSION = "1.0";
27 $num = 1;
29 my @ins = ();
30 my %ins = ();
32 my $last_seen = '';
34 my $offset = 0;
36 while(<>)
38 chomp;
40 if(my ($sample, $start, $end) =
41 (/"([^"]+)".*Start=(\d+), End=(\d+),/))
43 my $i;
45 $i->{sample} = $sample;
46 $i->{filename} = "${num}_${sample}.wav";
47 $i->{base} = 0;
48 $i->{min} = 0;
49 $i->{max} = 0;
50 $i->{start} = $start;
51 $i->{end} = $end;
53 push(@ins, $sample);
54 $ins{$sample} = $i;
56 $num ++;
58 elsif(my ($sample) = (/^\s+Sample \d+\) "(.+)"/))
60 my $i;
62 $i->{sample} = $sample;
63 $i->{filename} = "${num}_${sample}.wav";
64 $i->{base} = 0;
65 $i->{min} = 0;
66 $i->{max} = 0;
68 push(@ins, $sample);
69 $ins{$sample} = $i;
71 $num ++;
73 elsif(/^\s+Region \d+\) Sample: "(.+)"/)
75 $last_seen = $1;
77 elsif(/^\s+KeyRange=(\d+)-(\d+)/)
79 $ins{$last_seen}->{min} = $1 + $offset;
80 $ins{$last_seen}->{max} = $2 + $offset;
82 # set base as min if it's not looped, as they
83 # seem to have always 60
84 $ins{$last_seen}->{base} = $ins{$last_seen}->{min}
85 unless $ins{$last_seen}->{start};
87 elsif(/^\s+Sample: "$last_seen",.*UnityNote=(\d+)/)
89 # set only if wave is looped
90 if($ins{$last_seen}->{start})
92 $ins{$last_seen}->{base} = $1 + $offset;
98 print "/* converted by gigdump2ahs.pl $VERSION */\n\n";
100 foreach my $i (@ins)
102 $i = $ins{$i};
103 print "{ wav \"$i->{filename}\" $i->{base} $i->{min} $i->{max} $i->{start} $i->{end} }\n";