summaryrefslogtreecommitdiff
path: root/midicsv-1.1/exchannel.pl
blob: b1fcde8484048412dd9b237906b02794938554a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    #	Extract events for a channel from a MIDI CSV file.
    #	All non-channel events are output unchanged.
    #	Comments are discarded.
    
    $which_channel = 9;     	# Extract General MIDI percussion for demo
    
    while ($a = <>) {
    	if (!($a =~ m/\s*[\#\;]/)) { 	# Ignore comment lines
	    if ($a =~ m/\s*\d+\s*,\s*\d+\s*,\s*\w+_c\s*,\s*(\d+)/) {
    	    	if ($1 == $which_channel) {
		    print($a);
		}
	    } else {
	    	print($a);
	    }
        }
    }