midi note length

Questions and discussion about building and using Max for Live devices
elt.net
Posts: 62
Joined: Fri Jul 29, 2005 11:02 pm
Contact:

midi note length

Post by elt.net » Tue Mar 14, 2017 4:36 pm

hello, how to get the duration of currently midi note played in midi clip ? thx.
--------------------
www.altersessio.net
--------------------

chapelier fou
Posts: 5063
Joined: Mon May 15, 2006 12:15 pm

Re: midi note length

Post by chapelier fou » Tue Mar 14, 2017 5:33 pm

call "get_notes" on the target clip, and concurrently observe "playing_position".
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
iMac 27" Retina i5 3,2 GHz OS 10.11.3 L10.0.1 M4L.

doubleUG
Posts: 138
Joined: Sun Apr 24, 2011 7:19 am

Re: midi note length

Post by doubleUG » Tue Mar 14, 2017 5:36 pm

notein > borax

borax reports the duration at note off.

elt.net
Posts: 62
Joined: Fri Jul 29, 2005 11:02 pm
Contact:

Re: midi note length

Post by elt.net » Tue Mar 14, 2017 10:15 pm

yep. thx.

- borax doesn't fir as I need duration at note on.

- "get_note" & "playing_position" : yes I supposed something like that but I can't achieve it. could you share the code please ?
--------------------
www.altersessio.net
--------------------

chapelier fou
Posts: 5063
Joined: Mon May 15, 2006 12:15 pm

Re: midi note length

Post by chapelier fou » Tue Mar 14, 2017 11:03 pm

elt.net wrote:yep. thx.

- borax doesn't fir as I need duration at note on.

- "get_note" & "playing_position" : yes I supposed something like that but I can't achieve it. could you share the code please ?
Don't have any code and no time for now, sorry !
With pleasure sometime later if there is no rush ?
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
iMac 27" Retina i5 3,2 GHz OS 10.11.3 L10.0.1 M4L.

elt.net
Posts: 62
Joined: Fri Jul 29, 2005 11:02 pm
Contact:

Re: midi note length

Post by elt.net » Wed Mar 15, 2017 4:46 pm

no prob. It was just in case you had it already. thx.
--------------------
www.altersessio.net
--------------------

broc
Posts: 1148
Joined: Mon Jul 26, 2004 8:37 am

Re: midi note length

Post by broc » Thu Mar 16, 2017 1:04 pm

chapelier fou wrote:call "get_notes" on the target clip, and concurrently observe "playing_position".
Nice idea but the timing will be problematic due to unpredictable latency of the Live API.
Just did a test with a clip note on beat 1.0 where the observer reports playing_position 0.85 (!)

chapelier fou
Posts: 5063
Joined: Mon May 15, 2006 12:15 pm

Re: midi note length

Post by chapelier fou » Thu Mar 16, 2017 3:11 pm

broc wrote:
chapelier fou wrote:call "get_notes" on the target clip, and concurrently observe "playing_position".
Nice idea but the timing will be problematic due to unpredictable latency of the Live API.
Just did a test with a clip note on beat 1.0 where the observer reports playing_position 0.85 (!)
Ah. Those latency issues are so frustrating.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
iMac 27" Retina i5 3,2 GHz OS 10.11.3 L10.0.1 M4L.

elt.net
Posts: 62
Joined: Fri Jul 29, 2005 11:02 pm
Contact:

Re: midi note length

Post by elt.net » Thu Mar 16, 2017 5:50 pm

ouch. ok I'll check it but I'm afraid it will not very useful…
--------------------
www.altersessio.net
--------------------

broc
Posts: 1148
Joined: Mon Jul 26, 2004 8:37 am

Re: midi note length

Post by broc » Thu Mar 16, 2017 8:50 pm

Notice that the latency problem can be eliminated under certain conditions. For example, if the clip notes are strictly quantized to 8th (0.5 beats), the observer output could be quantized accordingly using [round 0.5] to ensure accurate timing.

elt.net
Posts: 62
Joined: Fri Jul 29, 2005 11:02 pm
Contact:

Re: midi note length

Post by elt.net » Thu Mar 16, 2017 10:12 pm

yes absolutely right. but unfortunately I plan to do something not quantized at all. ;-)
--------------------
www.altersessio.net
--------------------

chapelier fou
Posts: 5063
Joined: Mon May 15, 2006 12:15 pm

Re: midi note length

Post by chapelier fou » Thu Mar 16, 2017 10:41 pm

Maybe tell us what you want to achieve ?
Sometimes it's good to have a different point of view, as there might be another way to do it.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
iMac 27" Retina i5 3,2 GHz OS 10.11.3 L10.0.1 M4L.

elt.net
Posts: 62
Joined: Fri Jul 29, 2005 11:02 pm
Contact:

Re: midi note length

Post by elt.net » Fri Mar 17, 2017 11:27 pm

yes for sure I'll do asap. we're a little bit busy now. thx.
--------------------
www.altersessio.net
--------------------

elt.net
Posts: 62
Joined: Fri Jul 29, 2005 11:02 pm
Contact:

Re: midi note length

Post by elt.net » Tue Mar 28, 2017 9:38 am

Just a tip (I didn't take time to explore yet) but it seems [borax] should do the job… no ?

Edit: ha No, duration is sent at noteoff, and I need it at noteon…
--------------------
www.altersessio.net
--------------------

broc
Posts: 1148
Joined: Mon Jul 26, 2004 8:37 am

Re: midi note length

Post by broc » Tue Mar 28, 2017 12:08 pm

There may be a solution by giving each note a unique number:

1. Load the clip notes into a coll with index numbers, sort by start times and renumber the indices.

2. At playback count the note-on events and get the corresponding duration from coll.

Post Reply