Filtering out specific notes from MIDI files

From: Stanisław Raczyński <sutashu_at_gmail.com>
Date: Thu Dec 10 2009 - 07:27:29 CET
Hi,

I have a very simple task at hand: process a MIDI file and remove all note
events with MIDI note number different than a given number. It can't get any
simpler than that.

I have to process hundreds of files, creating 88 separated MIDI files for
each of the input file, so it would probably have to be a command-line tool.
I could have written a small C program to do it (I have delta-time
decoding/encoding functions lying around somewhere), but it would take me a
day or two and I'm a lazy guy. So instead I set out to find a tool suitable
for my purpose and found midish. It's really great, but after a long fight
with the sometimes mysterious commands, I came to believe that midish can't
really do it.

Here's what I have created after reading the whole manual (back and forth a
couple of times) and the mailing list (assuming I want to filter out
everything which is not MIDI note #69):

import "input.mid"
sel 10000
for trk in [tlist] { ct $trk; tevmap {note {} 0..68} {none}; }
for trk in [tlist] { ct $trk; tevmap {note {} 70..127} {none}; }
export "output.mid"

However, it does not work, telling me that I should:

use the same cmd for 'from' and 'to' args
use the same cmd for 'from' and 'to' args
use the same cmd for 'from' and 'to' args
use the same cmd for 'from' and 'to' args
use the same cmd for 'from' and 'to' args

which, frankly, doesn't help me to understand the problem.

The above code only seems to work if I am very precise about the events I
want to filter and don't use the "none" events as well as any ranges. The
following, for example, works:

import "input.mid"
sel 10000
for trk in [tlist] { ct $trk; tevmap {note {} 69} {note {} 68}; }
export "output.mid"

Could you please tell me what is the way to go and if it's even possible in
the current midish version.

Best wishes,
Stanislaw
Received on Thu, 10 Dec 2009 15:27:29 +0900

This archive was generated by hypermail 2.1.8 : Wed Nov 08 2017 - 16:32:21 CET