set thePatch to 3
tell application id "com.figure53.QLab.5" to tell front workspace
make type "audio" -- set audio cue template in settings to all parameters that are not modified by this script
set theCue to the last item of (selected as list)
set the audio output patch number of theCue to thePatch
end tell
tell application id "com.figure53.QLab.5" to tell front workspace
--template cue 1
set theTempCue to cue "T1"
set theTemplate to properties of theTempCue
make type "audio" -- set audio cue template in settings to all parameters that are not modified by this script
set theCue to last item of (selected as list)
--delete any of the parameters you don't want to copy from the template cue by deleting lines of code below
set the audio output patch id of theCue to the audio output patch id of theTemplate
set the q name of theCue to ("Based on " & the q list name of theTemplate)
set the infinite loop of theCue to the infinite loop of theTemplate
--add any other parameters you want to copy from the template cue to the newly created cue here
end tell
-- make audio cues from files with templates
tell application id "com.figure53.QLab.5" to tell front workspace
-- ask user for folder where audio files
set myfolder to POSIX path of (choose folder with prompt "Choose folder with audio files" default location (path to music folder))
-- get list of wav files in that folder (we need quoted form of to handle folder names with spaces)
set myAudioFiles to (every paragraph of (do shell script "ls " & (quoted form of myfolder) & "/*.wav")) as list
-- set the start cue number
set cueNum to 6
-- make audio cues for every wav file in the user specified folder
repeat with myfilepath in myAudioFiles
if myfilepath contains "gone" then -- contrived example
-- make cue using template 2 handler; cue specific parameters are file target, main level and cue number
set audioCue to my makeAudioTemplate2(myfilepath, -32, cueNum)
else
set audioCue to my makeAudioTemplate1(myfilepath, -28, cueNum)
end if
set cueNum to cueNum + 1
end repeat
end tell
on makeAudioTemplate1(fileTarget, mainlevel, cueNum)
-- for "template 1" we set the prefix to B, the audio patch to 2 and some levels
-- this is just a contrieved example - adjust as needed
set audioPatchNum to 1
set prefix to "B"
set template1levels to {0, 0, -18, -21}
return my makeAudio(fileTarget, mainlevel, cueNum, prefix, audioPatchNum, template1levels)
end makeAudioTemplate1
on makeAudioTemplate2(fileTarget, mainlevel, cueNum)
return my makeAudio(fileTarget, mainlevel, cueNum, "C", 2, {-6, -18, 0, -6})
end makeAudioTemplate2
on makeAudio(fileTarget, mainlevel, cueNum, prefix, patchnum, mylevels)
tell application id "com.figure53.QLab.5" to tell front workspace
make type "audio"
set audioCue to last item of (selected as list)
-- template parameters
set audio output patch number of audioCue to 2
-- set some leves for columns 1 to ..
set ch to 1
repeat with mylevel in mylevels
audioCue setLevel row 0 column ch db mylevel
set ch to ch + 1
end repeat
-- cue specific parameters
set file target of audioCue to fileTarget
audioCue setLevel row 0 column 0 db mainlevel
set q number of audioCue to prefix & cueNum
-- we leave the cue name to be the default name
set notes of audioCue to "created by script " & ((current date) as string)
return audioCue
end tell
end makeAudio
tell application id "com.figure53.QLab.5" to tell front workspace
-- **declarations**
set currentTIDs to AppleScript's text item delimiters -- store current TIDs
set AppleScript's text item delimiters to "; " -- sets new TIDs
set theindex to 1
set patchList to {} -- create an empty list, this will become our patch selection list later
set exitFlag to false -- the trigger to end our output patch name generation loop
set workspaceName to q number -- for UI Scripting cue template. stores workspace name as a variable
set settingsWindow to (workspaceName & " — Settings") -- for UI scripting. stores the name of front workspace's settings window
set theOffset to 3 -- for UI scripting. lets us ignore the first three elements of the "Audio Output Patch" pop-up menu, which aren't useful
if (count (cues whose q type is "Audio")) is 0 then
make type "audio"
set patcher to last item of (selected as list)
else
set patcher to first cue whose q type is "Audio"
end if
-- **generate list of active audio output patches**
repeat until (exitFlag is true)
set audio output patch number of patcher to theindex
set patchName to audio output patch name of patcher
if audio output patch number of patcher is not theindex then -- if you've run out of audio patches, the repeat ends
set exitFlag to true
else
copy (text items of patchName) to end of patchList -- adds each audio patch name to our list
set theindex to theindex + 1
end if
end repeat
-- **display a "choose from list" pop-up with the items of our audio output patch list**
set chosenPatch to choose from list patchList with prompt ("Which audio patch would you like to use?" & return & return & "This will affect ALL AUDIO CUES in the current workspace!" & return) default items (first text item of patchList)
if chosenPatch is false then
return -- if user hits cancel, end the script here
else
set audioCues to ((cues whose q type is "audio") as list) -- define every audio cue in the workspace
end if
-- **set audio output patch of every audio cue in workspace to user's selection**
repeat with eachCue in audioCues
set audio output patch name of eachCue to chosenPatch
end repeat
-- **set target patch of workspace master level fades to user's selection. Delete this section if you don't want master output level adjustment cues**
if (count (cues whose q number is "resmas")) is 0 then
make type "fade"
set resMas to last item of (selected as list)
set target mode of resMas to target mode patch
set q number of resMas to "resmas"
set q name of resMas to "Restore Master Level @ 0dB"
setLevel of resMas row 0 column 0 db 0
end if
if (count (cues whose q number is "dipmas")) is 0 then
make type "fade"
set dipMas to last item of (selected as list)
set target mode of dipMas to target mode patch
set q number of dipMas to "dipmas"
set q name of dipMas to "Dip Master Level @ -20dB"
setLevel of dipMas row 0 column 0 db -20
end if
set patch target id of (cues whose q number is "resmas" or q number is "dipmas") to audio output patch id of patcher
-- **prompt user to change audio cue template**
display dialog "Want to change the audio cue template?" buttons {"Nah", "Yeah"} default button "Yeah" cancel button "Nah"
if button returned of result = "cancel" then
return
else
set patchNum to audio output patch number of patcher
tell application "System Events" to tell process "QLab"
click menu item "Cue Templates" of menu "Templates" of menu item "Templates" of menu "Workspace Settings" of menu item "Workspace Settings" of menu "File" of menu bar item "File" of menu bar 1 of application process "QLab" of application "System Events"
click button 3 of group 1 of splitter group 1 of window settingsWindow of application process "QLab" of application "System Events"
click UI element "Audio" of row 2 of outline 1 of scroll area 1 of splitter group 1 of window settingsWindow of application process "QLab" of application "System Events"
click pop up button 1 of group 1 of splitter group 1 of window settingsWindow of application process "QLab" of application "System Events"
click menu item (patchNum + theOffset) of menu 1 of pop up button 1 of group 1 of splitter group 1 of window settingsWindow of application process "QLab" of application "System Events"
end tell
end if
close window settingsWindow of application "QLab"
end tell
--
Contact support anytime: sup...@figure53.com
User Group Code of Conduct: https://qlab.app/code-of-conduct/
Instagram: https://www.instagram.com/Figure53
TikTok: https://www.tiktok.com/@QLab.app
Bluesky: https://bsky.app/profile/qlab.app
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/qlab/bb09592c-105b-4e7a-b629-d1181e68795cn%40googlegroups.com.