Skip to main content
Participant
October 27, 2023
Question

Trying to run a script that moves the starting time of my markers

  • October 27, 2023
  • 1 reply
  • 212 views

Hello I want to move the starting time of all my markers backwards half a second.
Chat GPT came up with this:

 

 

// Define the time offset (in seconds) to move the markers
var timeOffset = -0.5; // Half a second backward

// Get the active session
var activeSession = app.activeSession;

// Check if there's an active session
if (activeSession) {
  // Get all markers in the active session
  var markers = activeSession.markers;

  // Iterate through all markers
  for (var i = 0; i < markers.numMarkers; i++) {
    var marker = markers.getMarker(i);

    // Calculate the new position for the marker
    var newStartTime = marker.startTime + timeOffset;

    // Update the marker's position
    marker.startTime = newStartTime;
  }

  // Refresh the view to see the changes
  activeSession.view.refresh();
} else {
  alert("No active session found. Please open an audio file in Adobe Audition.");
}

 

my issue is that i keep getting the message  "No active seesionfound. please open an audio file in Adobe Audition." Any suggestions?

This topic has been closed for replies.

1 reply

SteveG_AudioMasters_
Community Expert
Community Expert
October 27, 2023

Open the list of markers in the session you want to re-time. Then use File>Export>Selected Markers to CSV. Open this in a spreadsheet, do the manipulation there, and import the results back into your session. This will be quicker and way less frustrating than trying to explain to ChatGPT what it got wrong. I've tried that; it's quicker to write the code yourself.

 

In this instance, it's got confused between a file and a session. This is information that you have to spell out very carefully, otherwise it will screw you over every time.

Participant
October 30, 2023

Thanks for the reply Steve, exporting and resetiing the markers and then reimporting was my last resort, I am a c# developer I can automate that process, I was just hoping to do it with a JSX script inside audition. Its a shame there is no guide on how to code it in JSX. We have about 20 sound files with 60 markers each.
Do you  happen to know the code in JSX to store the markers of the opened file in audition in a variable? Because after that the logic seems correct.