Studio API - Get NamedMarkers in the order thay are in the logic track

Hello!

I have the following code to extract the name of NamedMarkers in a specific logic track:

Blockquote
allEvents.forEach(function (event) {
var markerTrack = event.markerTracks[2];
var destinationMarkerNames = ;
markerTrack.markers.forEach(function (marker) {
if (marker.isOfExactType(‘NamedMarker’)) {
destinationMarkerNames.push(marker.name);
}
})
}

I aim to get the names and store them in a user property, which I can already do. The main issue is that the names are not ordered in the same way I have them in my logic track, and I was wondering if there is a way to store them based on the order they have in my logic track, e.g.:

Logic Track: Intro, SectionA, SectionB, Ending
Exported Value from code: Ending,SectionA,Intro,SectionB

I want the export order to mimic the logic track order. Is this possible?

1 Like

Unfortunately, there’s currently no way to have Studio that the order of markers in the marker track will be in order. I would recommend adding each marker to an array, sorting them with Array.sort() based on (at minimum) the position of each marker, though you may also want to add additional sorting for multiple marker tracks, alphabetical order, etc. depending on your needs.

As a basic example:

function compareMarkers(a, b) {
	return a.position - b.position;
}
var markerArray = markerTrack.markers;
markerArray.sort(compareMarkers);
1 Like

Hello, Leah,

Thank you so much for the answer. It’s a shame there is no direct way. I will probably use the marker’s position to sort through the array. Thank you for suggesting other sorting methods as well!

Regarding the member properties and overall structure of the JavaScript implementation of FMOD, are there any links that clearly state these members and what is accessible through the JavaScript code? The Studio API documentation does not clearly state all the members, functions, and accessible elements. I haven’t seen in the API docs the syntax that you use “markerTracks.markers” and the like. Is there any official documentation for this or a link online that I can check that delves deeper into the internal structure?

Thank you again for your reply! I look forward to hearing back from you. Have a great rest of your week.

1 Like

Though we are making improvements, the documentation around the Studio Scripting API is admittedly lacking and outdated in areas at the moment. Our general recommendation is make liberal use of the .document() and .dump() functions in the Studio console. These are able to be used with all Studio API ManagedObjects (which comprise most of a project), and will print a list of all members and functions of that object to console, including the object’s values in the case of .dump().

1 Like