Master Marker Manipulation

This chapter deals with ways of importing markers from other programs (including ProTools session markers) as slice markers in QLab, and exporting slice markers from QLab for use with other programs.

Many of the examples use TwistedWave as the audio editor. It is beyond our resources to test and provide solutions for every Mac audio editor; TwistedWave has been selected because it’s capable, lightweight, fast, inexpensive, and comes with a free 30-day trial. Other audio editors may well provide similar (or even superior) capabilities, but you will need to explore and test these yourself.

The methods described here to export slice markers from QLab produce standard .xml files that work with many programs.

Example 1: Importing markers from an audio file

This is, to begin with, a straightforward process.

If you place markers in an audio file in TwistedWave and save the file, they show up as slices in QLab Audio cues that target that file.

Synced markers

If you have markers that have been added in other programs that TwistedWave recognizes and displays as markers, those will work in exactly the same way.

As long as the slice markers in the QLab cue and the audio file are the same, you can edit markers in the audio editor and the QLab cue will update automatically when the audio file is re-saved.

The relationship breaks whenever anything relating to slices are adjusted in QLab, or when changes are made in the external audio editor while the QLab workspace is not open.

Once QLab decides the sync relationship is broken, the slice markers which exists in the cue will persist unless deleted or moved within QLab. Retargeting an existing cue will not import any new markers as slices. Setting a new target audio file with no markers will not clear existing markers in the cue.

Remember, QLab never edits the source file, so no matter what happens in QLab, the audio file and its internal markers will never be altered.

Example 2: Importing markers from a ProTools session

In ProTools, markers are created in the session on the ruler, rather than in individual audio files. They are not standard markers as defined by the WAV and AIFF file formats; they’re different.

ProTools Markers

Bouncing down a session to an audio file does not include the session markers in the bounced audio file.

Through a slightly involved process, however, you can get your session markers converted to audio markers that QLab will import as slices when a cue is created targeting that audio file.

First, ensure all markers are absolute (i.e not bar’beat)

Absolute marker

Next, bounce or export your audio from ProTools to an audio file starting at session time 0:00:00.

Then, choose Export Session Info As Text from the File menu and deselect everything apart from Include Markers Set Time Format to “Mins:Secs” and File Format to “TextEdit ‘TEXT’“.

Export session text

The resultant text file will look something like this:

ProTools text export

You then need to open the audio file in an audio editor capable of recognizing and parsing a ProTools session text file. TwistedWave does this nicely, and is used in this example.

Surround audio file

In TwistedWave, choose Import Markers… from the Markers menu, and select the session info text file from ProTools:

Import markers

Save the audio file, and you now have an audio file with regular markers that QLab can convert into slice markers in the normal way.

ProTools markers in QLab

Example 3: Importing chapters from a .mov file

This technique opens the target video file of the selected cue in QuickTime Player, and sends the key combination to QuickTime player to step through all the chapters in the video. The script grabs each chapter time and creates a slice marker in the associated cue.

Here it is in action, best viewed full screen:

Here’s the script in the Script cue in the example workspace:

--requires QLab 4.1.2 or later
set oldtime to -1
set thetime to -2
tell application id "com.figure53.QLab.4" to tell front workspace
	set theCue to last item of (selected as list)
	set thetarget to file target of theCue
	tell application "Finder" to open thetarget
	delay 2
	tell application "QuickTime Player" to set the current time of front document to 0
	tell application "System Events" to key code 124 using {command down, shift down}

	repeat
		tell application "QuickTime Player"
			activate
			delay 0.1
			set thetime to current time of front document
			if thetime = oldtime then exit repeat
		end tell

		tell application id "com.figure53.QLab.4" to tell front workspace
			activate
			set theTimeAsText to (thetime as text)
			set allSlices to (slice markers of theCue)
			set the end of allSlices to {time:theTimeAsText, playCount:1}
			set the slice markers of theCue to allSlices
			set oldtime to thetime
		end tell

		tell application "QuickTime Player"
			activate
			tell application "System Events" to key code 124 using {command down, shift down}
		end tell
	end repeat

	tell application "QuickTime Player"
		quit
	end tell
end tell

First we get the selected cue.

We open its target in the default application, which is assumed to be QuickTime Player X. If that’s not the case, this script may not work properly. Once the file is open, we rewind it to the beginning just in case it’s not there already.

We go to the next chapter mark (which will probably be chapter 2, as chapter 1 starts at the beginning of the file) by sending the key combination ⇧⌘→ (command-shift-right-arrow).

We get the current time of QuickTime Player.

We add a slice at that time by getting a list of all the slices in the cue, appending that list with the new slice, and setting the cue’s slices to the newly appended list of slices.

We then repeat this until the current time returned from QuickTime Player is the same as the previous iteration of the repeat loop, indicating there are no more chapters in the video file.

Example 4: Export slice marker times from QLab to .xml file

This technique opens the targeted audio file of the selected cue in an audio editor, and if there are slice markers in the cue exports the slice number and it’s location both as samples and time to a .xml file that can be read by TwistedWave.

This is helpful if you’ve set a bunch of slice markers in a cue, and wish to save those slice markers into the source audio file for use in future cues.

Here’s the script:

set theDAW to application “TwistedWave” — Name of your editor goes here!
set thexml to “” & return
tell application id “com.figure53.QLab.4” to tell front workspace
  set thecue to last item of (selected as list)
  set thefile to (file target of thecue) as alias
  if q type of thecue is “Audio” then
    ignoring application responses
      tell theDAW
        open thefile
        activate
      end tell
    end ignoring
  end if
  set myslices to slice markers of thecue
  set listnumber to number of items in myslices
  if listnumber is 0 then return
  set sampleRate to do shell script “mdls ” & quoted form of POSIX path of thefile & ” | grep \”kMDItemAudioSampleRate\” | awk ‘{print $3}'”
  repeat with eachcue from 1 to listnumber
    set thexml to thexml & “” & return & “Marker ” & (eachcue as string) & “” & return & “” & (sampleRate * (time of item eachcue of myslices) as integer) & “” & return & “” & ((time of item eachcue of myslices) as text) & “” & return & “” & return
  end repeat
end tell
set thexml to thexml & “”
tell application “System Events” to set target_file to ((((path to desktop folder) as string) & (name of thefile) & “Markers.xml”))
try
  set append_data to false
  set the target_file to the target_file as string
  set the open_target_file to open for access file target_file with write permission
  if append_data is false then set eof of the open_target_file to 0
  write thexml to the open_target_file starting at eof
  close access the open_target_file
  return true
on error
  try
    close access file target_file
  end try
  return false
end try

The script gets the selected cue from the QLab workspace, then opens the target audio file of the cue in the audio editor set at the top of the script.

If there are slice markers in the cue then it counts them.

It then gets the sample rate of the file. This is quite tricky as a lot of the AppleScript methods to do this don’t work as expected. The following does work, and can also be applied to other types of media files:

set sampleRate to do shell script “mdls ” & quoted form of POSIX path of thefile & ” | grep \”kMDItemAudioSampleRate\” | awk ‘{print $3}'”

We need the sample rate so that we can include the sample number for the position of the marker in the .xml file

We then construct the contents and formatting of the .xml file which looks like this:

Markers XML

and output it to an .xml file named so as to identify which file it refers to. For example:

PNO Finale PNOSHORT.aifMarkers.xml

This file can then be imported into TwistedWave by choosing Import Markers… from the Markers menu and selecting the .xml file. When the audio file is saved in TwistedWave, the markers are then embedded for use in future cues. TwistedWave can also split a file by markers so you can easily create a file for each section between slices.

TwistedWave is a registered trade mark of TwistedWave Software, LTD.

ProTools is a registered trade mark of Avid Technology, Inc.