How to tell if a note has been played during the last x ms ?

chapelier fou's icon

Seems simple, but I can't figure it out.
Let's say you've got midi notes coming in. For each note check if it was played during the last 1000 ms.
Any help ?

Came up with this, not sure it's the best :

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

Source Audio's icon

1- are you only taking note on (held note) or also note Off (note is gone)
into account ?
2- what is last 1000 ms ?
a continuous running clock that looks in the past if note x is still "ON" ?
3. do you want to report all 128 note states in updating 1000 ms window ?

patch you posted has nothing of above mentioned implemented.

double_UG's icon

Please provide at least 10 characters

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

chapelier fou's icon

Thank you both !
I came up with this solution above, seems ok...(?)
I'm just trying to avoid very close repetitions of the same note.
I'm working on a pitch quantizer that works polyphonically. When two different notes that are rounded to the same note come out simultaneously, it results in a 'double note'. When driving some synths, it produces an unpleasant result. I want to detect when it happens, so I can either remap the note differently or just cancel it.

Source Audio's icon

If you have multiple overlaping notes of same pitch coming in,
either by transposition, multiple input sources etc,
you need as first to decide what to do with them.
You will have some sort of a problem anyway if you use
note off messages at all.
cleanest solution I can think off is to use poly~
with128 voices, and insert the logic in there.
I would use makenote with it's repeat modes set to what you prefer at the end.


tyler mazaika's icon

You can get away with no cpuclock testing/storage if you instead just store a status which indicates "pitch was received in last <n> window". SA is right though... always need to have a solution in mind for notes off.

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

chapelier fou's icon

Thanks,
I'm always finding myself in this kind of situations with notes off. Something is wrong with my brain.