Maximum midi note length

Sam Verlen's icon

Hello,

I'm trying to find a way to force a midi note-off if a midi note-in duration is upper than a given user value (for example 2 seconds).

I guess borax could help for that but I didn't find an appropriate way to do that with polyphonic for the moment. And I didn't find this type of request in the forum previously.

Thanks for your help.

double_UG's icon

a quick patch, I haven´t tested if it works this way

Max Patch
Copy patch and select New From Clipboard in Max.

Sam Verlen's icon

Thank you very much for your quick proposal @DOUBLE_UG !


In fact, it is the inverse behavior that I'm trying to achieve:
Let say "MaxLength" is defined by the user to 2 seconds, all the notes that have a shorter duration should not be affected and the longer ones (more than 2 seconds) should have a duration maximized at 2 seconds.

The other difficulty that I forgot to explain is that I'd like to do this on the fly on live input midi. So maybe, metro should be used there to take into account the current DAW time.

Source Audio's icon

notein set to 2000ms

Sam Verlen's icon

Sorry "Source Audio", I do not understand what you have in mind. Do you mean using "makenote" with a standard duration (2000 msec) ?

tyler mazaika's icon

I think this will work if you throw it in a poly~ with a bunch of voices.

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon
Roman Thilenius's icon

where do these notes come from?

if you generate them yourself and use makenote anyway, you´d limit the length using [clip]:

but if you have a midi stream already you need a little gate mechanism somewhere which chooses to either automatically end a note or not, and do all of this after splitting up the events using [poly].

double_UG's icon

Max Patch
Copy patch and select New From Clipboard in Max.

Sam Verlen's icon

Thank you very much for all your replies.
The midi notes are played in live with my keyboard Arturia and comes in Ableton on a given channel. So I can get those with "notein" and I want to keep the midi notes that have a duration lower than 2000 msec as they were played and only make a noteoff on notes which length is upper than 2000 msec.

Example :

"Notein" receives a "60 127" and the duration before "noteoff" (60 0) is 500 msec, nothing is done.

"Notein" receives a "62 127" and the duration before "noteoff" played (62 0) is 2500 msec, the algorithm detects in real time that I took more than 2000 msec since "notein" and sends a "noteoff" at 2000 msec.

So I think I could not use makenote as I do not want to generate new notes with a constant duration.

Source Audio's icon

It seems to be too big challenge to create that simple makenote object and test it

Sam Verlen's icon

My apologies "source audio", it well works with makenote, I did not understand that it behaves like that in the manual. Thank you very much, it becomes a very simple module finally...
And thank you all for your replies, I tested everything and it enables me to start with max algorithms.

Eric Moon's icon

seq~ handles stuff like this nicely.

here, a seq~ is set up to play stored events over a 2 second period (controlled by the phasor~). incoming note on pitches get written to the sequence, and are played back as note offs. whenever a note off is played, that pitch is removed from the sequence.

Max Patch
Copy patch and select New From Clipboard in Max.

Sam Verlen's icon

Thanks Eric Moon, this is really interesting, it well works also and I may use it for other applications.
I'd love to make a pipe-organ like dynamical stops: add/remove octaves (or quinte/tierce) dynamically on current activated input midi notes. And unfortunatly, Ableton chord plugin does not manage that.

Source Audio's icon

You collect all currently sounding notes into for example coll,

and duplicate / transpose all of them as many times as needed per "stop".

when "stops" get removed, turn all notes of that "stop" off.

a bit of logic arround enabled "stops" needs to be done,

in moment of note arrivals and when "stops" get added or removed.

Start with single note for testing

this will give you an idea how to add or remove notes from coll.

You need to dump or grab that notes to process them further