summaryrefslogtreecommitdiff
path: root/midicsv-1.1/exchannel.pl
diff options
context:
space:
mode:
Diffstat (limited to 'midicsv-1.1/exchannel.pl')
-rw-r--r--midicsv-1.1/exchannel.pl18
1 files changed, 18 insertions, 0 deletions
diff --git a/midicsv-1.1/exchannel.pl b/midicsv-1.1/exchannel.pl
new file mode 100644
index 0000000..b1fcde8
--- /dev/null
+++ b/midicsv-1.1/exchannel.pl
@@ -0,0 +1,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);
+ }
+ }
+ }