Getting length of a selection in seconds.milliseconds

Learn about building and using Max for Live devices.
Post Reply
lapieuvre
Posts: 786
Joined: Wed Sep 26, 2007 9:29 pm

Getting length of a selection in seconds.milliseconds

Post by lapieuvre » Tue Apr 07, 2026 3:08 pm

I'd like a max patch that calculates the length of a selection. Claude and Gemini can't help me.

The reason for this, I need to calculate the average tempo of a section when there is tempo automation. I need this to bring the music in Session View.

For example, if I have a 4 bars accelerando, I can't bring that to Session view. The only way I found was to calculate the average tempo of those 4 bars. Ex. : 4 bars accel from 120 to 135Bpm, when I select these 4 bars, Live tells me (bottom left) it is 7.625 sec.

I do 16 beats (4 bars) * 60 / 7.625 = 125.90 BPM average.

If I bring those 4 bars in session view, and write a tempo of 125.90, then it will play fluidly to the next scene.

This Max Patch would calculate it automatically when I select those 4 bars, because going manually takes time. I do a lot of music with tempo automation.

Thanks,
MBP M1 Max 64 GB Ram, OSX 15.7.4
Live 10.1.43 Suite
Live 11.3.35
Live 12.3.6
Interface : RME Fireface UCX

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

Re: Getting length of a selection in seconds.milliseconds

Post by chapelier fou » Wed Apr 08, 2026 2:15 pm

It's tricky because it depends on the tempo automation curve.
If you restrict it to linear segments, maybe it's simpler to calculate ?
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

lapieuvre
Posts: 786
Joined: Wed Sep 26, 2007 9:29 pm

Re: Getting length of a selection in seconds.milliseconds

Post by lapieuvre » Wed Apr 08, 2026 2:24 pm

chapelier fou wrote:
Wed Apr 08, 2026 2:15 pm
It's tricky because it depends on the tempo automation curve.
If you restrict it to linear segments, maybe it's simpler to calculate ?
It's the only place I need the length, in the automation sections, because it doesn't translate in session view. Live already tells me the length, bottom left when I select something. This value is not "copy-able"?
MBP M1 Max 64 GB Ram, OSX 15.7.4
Live 10.1.43 Suite
Live 11.3.35
Live 12.3.6
Interface : RME Fireface UCX

Post Reply