Help!

Matthew Cartwright's icon

MAXPATCHPROJECT.maxpat
Max Patch
Hi all, I am currently working on a patch that takes midi information from a DAW and checks for clashes between MIDI notes. I plan to use this on my demo tracks (which I make in MIDI) to check for any possible clashing frequencies before recording actual instruments only the find the arrangement isnt working. So far I have managed to get MAX to recognise the notes that are coming from my DAW (I use Logic) however, I need to find a way that MAX can detect the moment a clash occurs. My current setup detects every time a new note in played in my DAW rather than just a clash (I can see this through the button which I have temporarily placed at the bottom of my patch). Anyone got any suggestions? Sorry ifI am missing the obvious here, I am new to MAX!

dsmd's icon

If you attach the bang to the left output of [sel -1] it detects when the same note is played.
Is that what you mean with a clash?

Matthew Cartwright's icon

By clash I mean whenever 2 notes are played in my DAW at the exact same pitch on 2 separate channels at the same time. For example if C3 is played on channel one and C3 is being played on channel two simultaneously this WOULD be a clash, but if C3 is being played on channel one and D3 is being played on channel two is WOULD NOT be a clash. At the moment my patch is detecting every time a new note is played in my DAW rather than detecting only the clashing notes.

So I've got 2 separate Logic MIDI channels open, both are being sent to MAX 1 channel 1 (for my first channel) and MAX 1 channel 2 (for my second channel). The "attrui" object lets me select MAX 1 for my MIDI data from logic to be sent to the "notein" object in MAX.

This is then connected to the "pak" object with the MIDI channel being inputed first followed by the pitch data. Iv'e done it this way round as the "route" object matches a message's first argument to it's own arguments. So channel one will be outputted via route output 1 and channel two will be route output 2 etc. as the midi channel is the first argument / element in the "pak".

This is then connected into the two integers which display the current pitch / MIDI note being played in the relative channel of the DAW, however, I am struggling to find a way to compare the two to determine when a clash occurs.

I thought my "if" object would be able to detect when this happened by saying when integer one matches integer two, to output integer one (as this would be the note which is clashing at that exact moment).

Im sorry if i haven't explained that very well and I realise this message is rather long winded so thank you for your patience!

Roman Thilenius's icon


u could take the incoming notes of all (16?) channels and send them to a "filter" in all other channels until the are released again.

as soon as you also want to do this for more than one running note per input channel, this isnt a trivial task at all.

you also have to decide (i.e. and tell us) what you want to do when there is a match. simply delete the later one, or what?

under circumstances it might make sense to design that using list processing.

Matthew Cartwright's icon

When there is a match I am wanting for MAX to be able to timestamp at exact moment of the clash. As I am planning on using this on my demo arrangements, I am going to run the arrangement through it once the MIDI demo for a track is "finished".

This means the timestamped notes will be available in a list so I can go back to my arrangement at the point timestamped and stop my notes (and thus different instruments) from clashing frequency wise, so the notes are playing different pitches at every point throughout the arrangement with no clashes. I understand this isn't exactly necessary for composition but it's just a personal task I am undertaking.

dsmd's icon

you could collect all the currently held notes in a coll and cycle through them looking for a clash.
And as soon as you have one write the current time and note in another coll.

borax is a handy object to collect information about your notes. With the event number out of borax as an event(index) number you can store it in coll.
Then dump the content of coll and compare.

Matthew Cartwright's icon

Thanks guys, I’ll have a look and keep you posted on any developments :)