Can I calculate the total number of Markers in a project in a MIDI Remote script?

Hi All,

I made a fader in a .js file that lets me roll back and forth in my project by issuing “Locate Previous/Next Marker” commands and I’ve tweaked the feel to be nice and smooth. The thing is that this current project has 55 markers. Of course when it was brand new, it had 0.

Is there a way for me to get the total number of Markers in a project or on a track using the API ?

I want my fader/scrub code to automatically scale up as I add new Markers over time.

Also fwiw, all my Markers are on the same track.


Out of the box, no.
However, if you plan to add markers only by using the remote, then yes it’s possible, however you then have to take into account the chance of deleting a marker. This has to be further coded by using a binding to the delete command and there check if the current cursor position is in the array of markers, and even then, you have to be careful with using the delete, only when in the markers track in order for it to work as expected.

Out of curiosity, could you please explain a bit more why exactly you need this? I just didn’t understand the scale-up purpose here.

Anyway, here’s a snippet for setting the count and the markers, when using the remote for this:

page.makeCommandBinding(buttonMarker.mSurfaceValue,'Transport', 'Insert Marker').mOnValueChange=function(activeDevice,activeMapping,value,diff){


        var markersCountStr=activeDevice.getState("markersCount")
        var markersCount=markersCountStr=="" ? 0 : parseInt(markersCountStr)

        //we can even save the markers




    activeDevice.setState("currentPosition",value1+" "+value2)