Skip to content
Snippets Groups Projects
lspatch.pl 7.26 KiB
#!/usr/bin/perl

# TiMidity++ -- MIDI to WAVE converter and player
# Copyright (C) 1999-2004 Masanao Izumo <iz@onicos.co.jp>
# Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# lspatch.pl
#
# List the entire instrument configuration

my (@tonebank, @drumset);
my (@pathlist, @patch_ext_list);
my $rcf_count;
my $def_instr_name;
my ($cfg, $cfgroot);
my $MAX_AMPLIFICATION;

@pathlist = ( '.' );
@patch_ext_list = ( '', '.pat', '.shn', '.pat.shn', '.gz', '.pat.gz' );
$rcf_count = 0;
$MAX_AMPLIFICATION = 800;
if (@ARGV != 1) {
	print STDERR "Usage: $0 cfg-file\n";
	exit 1;
}
$cfgroot = $cfg = $ARGV[0];
if ($cfgroot =~ s/\/[^\/]+$//) {
	unshift(@pathlist, $cfgroot);
}
! &read_config_file($cfg) or exit 1;
$rcf_count++;
&lspatch('bank', @tonebank);
&lspatch('drumset', @drumset);
exit 0;

sub read_config_file
{
	my ($name) = @_;
	local *CFG;
	my ($status, $i, $x, $y, $k);
	my (@args, $bank, $orig_name, $line, $patch, @options);
	
	if ($rcf_count > 50) {
		print STDERR "Probable source loop in configuration files";
		return -1;
	}
	$orig_name = $name;
	undef $_;
	$name = &open_file(*CFG, $name) or return -1;
	undef $_;
	$line = 0;
	while (<CFG>) {
		$line++;
		s/^\s+|\r?\n$//;
		@args = split(/[ \t\r\n\240]+/, $_);
		next if @args == 0 || $args[0] =~ /^$|^#/;