MIDI chord splitter

jparker's icon

This shouldn't be a difficult task, but I'm not totally sure how to go about it.

I'd like to input a chord from a MIDI keyboard and have each note be sent to a separate port and channel. The patcher would wait for a specified number of notes to be played. For example, once four voices have been received, the patcher would sort them by pitch and then route the pitches to different destinations. All controller and velocity information needs to pass through as well.

What's the best way to get this result?

Roman Thilenius's icon

quick and dirty version

Picture-4.jpg
jpg
Roman Thilenius's icon

oh, i forgot the "sort by pitch".

Picture-5.jpg
jpg
broc's icon

@Roman

Nice solution, but I think it needs some correction since the left outlet from 'route 0' delivers only a single number (pitch).

Roman Thilenius's icon

ah right.

Picture-6.jpg
jpg
dhjdhjdhj's icon

Interesting, I've been working on a variation of this where I can play chords and the top note of the chord can be detected and routed somewhere else. The idea is to be able to layer a solo instrument over pads (say). It's a bit trickier as I can't depend on their being a certain (and exact) number of notes.

Right now I'm trying to use funbuffer objects to keep track of notes and then use 'max' to find the top note but it got so messy because, depending on the message you send out, you can get either the X or the Y value from the same left output so everything has to be gated.

Sigh

broc's icon
Max Patch
Copy patch and select New From Clipboard in Max.

If the number of chord notes is unknown you could collect them with a delayed bang.

dhjdhjdhj's icon

Yeah, I know --- but I have been trying to avoid any delays at all. I'm basically using a [borax] to index incoming notes and using (index, note number) as the parameter into a funbuff (and when velocity is 0, I delete from the funbuff) and then use a 'max' message to see what note is the highest when notes come in.

It works but the "code" is a little messier than I would like.

jparker's icon

ah right.

ATTACHMENTS:
Picture-6

This is working, but I'm getting a lot of hanging/stuck notes. Also, when I play four different notes, one pitch will often get doubled up. For example, if I play pitches 40 45 50 and 52, the max window will show 40 45 50 50 or 40 45 45 50.

Ideally, I'd like this patcher to handle 2-8 voices (i.e. you would select a number from a umenu object and then that message would be sent to the appropriate objects, telling the patcher how many voices to expect.

Thanks for your help.

Roman Thilenius's icon

yes, the whole approach with those two counters fails as son as note #2 ends before note #1 does.

sorry - i am usually working on higher symbolic levels without "note off".

the right counter for note off must be removed and replaced with a translation table based on the last 4 input not values.

cant do that offhand now ( if i´d do it will be wrong again) but maybe tomorrow with max.

meanwhile go compose something staccato for it ll work with the patch. :)