Fade cue - Nested Groups

112 views
Skip to first unread message

Mike Stephens

unread,
Jun 17, 2025, 3:34:56 PM6/17/25
to QLab
Hi folks, 

I have a partially working Fade Audio Script. However if I have nested groups it errors out stating no audio cues are found (which is part of my script) Is there a simple addition that I can add to my current script which fixes this issue?

Thanks all. M

This is my current script

set followon to "   [FO] "

tell application id "com.figure53.QLab.5" to tell front workspace

-- Confirm Edit Mode Active
if not (edit mode) then
display dialog "QLab is in Show Mode. This script requires user to be in Edit Mode." with icon caution buttons {"OK"} default button "OK"
return -- Stop the script
end if

-- Ensure at least one cue is selected
if (count of selected) > 0 then

-- Prompt user for fade-out time with Cancel option
try
set timeText to text returned of (display dialog "Set Fade-out time for all selected cues? (secs)" with title "Set Fade Duration" default answer "" buttons {"Cancel", "Enter"} default button "Enter")
on error
-- If the user clicks "Cancel", exit the script
return
end try

-- Convert input to an integer
try
set fadeTime to timeText as integer
on error
display dialog "Invalid input. Please enter a valid number." buttons {"OK"} default button "OK"
return
end try

-- Determine the cue naming prefix based on fade time
if fadeTime is 0 then
set fadePrefix to "CRASH - "
else
set fadePrefix to "FADE OUT - "
end if

-- Loop through each selected cue
repeat with originalCue in (selected as list)

-- Get cue type
set cueType to q type of originalCue
set audioCueName to q list name of originalCue

--- If Selection is an Audio file, construct fade out for selected cue(s)
if cueType is "Audio" then
-- Get original cue's volume level
set originalCueLevel to getLevel of originalCue row 0 column 0

-- Create Fade cue
make type "Fade"
set NewCue to last item of (selected as list)

-- Link Fade cue to the corresponding audio cue
set cue target of NewCue to originalCue
set duration of NewCue to fadeTime
NewCue setLevel row 0 column 0 db -255 -- Fade out to silence

-- Set "Stop target when done" to true so the cue stops when the fade completes
set stop target when done of NewCue to true

--Fix the name assignment
set q name of NewCue to fadePrefix & audioCueName

-- Move the Fade cue directly below the original cue
move NewCue to after originalCue

-- Set Format
set q color of NewCue to "Forest"
set q number of NewCue to ""

--- If Selection is a Group, make relative fade out over group
else if cueType is "Group" then
-- Get all child cues inside the group
set childCues to cues of originalCue

-- Check if the group has any Audio cues inside
set hasAudio to false
repeat with aCue in childCues
if (q type of aCue is "Audio") then
set hasAudio to true
exit repeat
end if
end repeat

-- If no audio cues are found, show a warning and exit loop
if hasAudio is false then
display dialog "No Audio Files Found In Group!" buttons {"OK"} default button "OK" giving up after 3
exit repeat
end if

-- Create a single Fade cue for the entire group
make type "Fade"
set NewCue to last item of (selected as list)

-- Link Fade cue to the Group cue
set cue target of NewCue to originalCue
set duration of NewCue to fadeTime

-- Fade out all Audio cues in the group
repeat with aCue in childCues
if q type of aCue is "Audio" then
NewCue setLevel row 0 column 0 db -255 -- Fade out to silence
end if
end repeat

-- Set "Stop target when done" to true so the group stops when fade completes
set stop target when done of NewCue to true

-- Fix the name assignment
set q name of NewCue to fadePrefix & q name of originalCue

-- Move the Fade cue directly below the Group cue
move NewCue to after originalCue

-- Set Format
set q color of NewCue to "Forest"
set q number of NewCue to ""

-- Place Playhead to new cue
set selected to NewCue

end if
end repeat

end if

end tell

Jeremy Lee

unread,
Jun 17, 2025, 10:56:01 PM6/17/25
to ql...@googlegroups.com
It’s been a while, but maybe you need to add “as list” to the end of this?
 
set childCues to cues of originalCue
--
Contact support anytime: sup...@figure53.com
User Group Code of Conduct: https://qlab.app/code-of-conduct/
 
Instagram: https://www.instagram.com/Figure53
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/ff846be5-11d8-40fd-b209-949d0b3ab0a6n%40googlegroups.com.

Rich Walsh

unread,
Jun 18, 2025, 4:05:22 AM6/18/25
to ql...@googlegroups.com
I’m not sure if this will do exactly what you want, but the form to handle nested groups is to replace:

repeat with originalCue in (selected as list)


With:

set cuesToProcess to (selected as list)


set containedIDs to {} -- We need to check for nested cues that are already selected so as not to add them twice; lists of "cues" can't be compared, only of IDs

repeat with eachCue in cuesToProcess

set end of containedIDs to uniqueID of eachCue

end repeat


set i to 0

repeat until i = (count containedIDs)

set eachID to item (i + 1) of containedIDs

set eachCue to cue id eachID

if q type of eachCue is "Group" then

repeat with eachChild in cues of eachCue

set childID to uniqueID of eachChild

if childID is not in containedIDs then

set end of cuesToProcess to eachChild -- Cue is not already selected, so add it for processing

set end of containedIDs to childID

end if

end repeat

end if

set i to i + 1

end repeat


repeat with originalCue in cuesToProcess


This will burrow down into groups in the selection and add their children to the end of the list to process as if they were also directly selected (and doesn’t add them again if they were already selected).

Rich

Mike Stephens

unread,
Jun 18, 2025, 4:50:24 AM6/18/25
to QLab
Thanks Rich,

Unfortunately it still didnt find any audio cues when using nested groups. I tried moving the new module to later in the script but still couldnt get it to function. Below is the updated script.

Really appreciate the support. 



-- Loop through each selected cue - check in nested cues

set cuesToProcess to (selected as list)

set containedIDs to {} -- We need to check for nested cues that are already selected so as not to add them twice; lists of "cues" can't be compared, only of IDs
repeat with eachCue in cuesToProcess
set end of containedIDs to uniqueID of eachCue
end repeat

set i to 0
repeat until i = (count containedIDs)
set eachID to item (i + 1) of containedIDs
set eachCue to cue id eachID
if q type of eachCue is "Group" then
repeat with eachChild in cues of eachCue
set childID to uniqueID of eachChild
if childID is not in containedIDs then
set end of cuesToProcess to eachChild -- Cue is not already selected, so add it for processing
set end of containedIDs to childID
end if
end repeat
end if
set i to i + 1
end repeat

repeat with originalCue in cuesToProcess

Rich Walsh

unread,
Jun 18, 2025, 5:06:55 AM6/18/25
to ql...@googlegroups.com
This is what happens when I run it with cue 1 selected. I don’t know what you expect it to do, but it’s definitely going to find all the cues inside a selected group.

Rich
Before.pngAfter.png

Rich Walsh

unread,
Jun 18, 2025, 8:21:27 AM6/18/25
to ql...@googlegroups.com
I literally copied and pasted your text below into Script Editor and ran it with a cue selected.

Rich

On 18 Jun 2025, at 10:44, Mike Stephens <mkstep...@gmail.com> wrote:

Yep that does not work for me. I get no audio cues found selected. Would you mind sending me the script from your side? Im sure ive missed something. 

<Before.png><After.png>
<Before.png><After.png>

Fade Cue.scpt
Message has been deleted

Mike Stephens

unread,
Jun 18, 2025, 12:32:51 PM6/18/25
to ql...@googlegroups.com
Thanks Rich. This now works for me. Clearly something had gone wrong my end. Thanks for the help!

--
Contact support anytime: sup...@figure53.com
User Group Code of Conduct: https://qlab.app/code-of-conduct/
 
Instagram: https://www.instagram.com/Figure53
Bluesky: https://bsky.app/profile/qlab.app
---
You received this message because you are subscribed to a topic in the Google Groups "QLab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qlab/IhUMsk4px70/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qlab+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/qlab/A9322104-3ADB-4395-A1D1-5DB260969A6A%40mac.com.

--
Contact support anytime: sup...@figure53.com
User Group Code of Conduct: https://qlab.app/code-of-conduct/
 
Instagram: https://www.instagram.com/Figure53
Bluesky: https://bsky.app/profile/qlab.app
---
You received this message because you are subscribed to a topic in the Google Groups "QLab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qlab/IhUMsk4px70/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qlab+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/qlab/A9322104-3ADB-4395-A1D1-5DB260969A6A%40mac.com.

Rich Walsh

unread,
Jun 19, 2025, 6:25:18 AM6/19/25
to ql...@googlegroups.com
I don’t really understand… If you can construct a sentence explaining the logic of what you want the script to do it’ll probably tell you how to do it, eg: “don’t make fades for groups contained within the outer group” which will probably mean something like testing for the q type of the parent of a Group Cue to see if it isn’t “Cue List”, and if so don’t make a fade…?

I only ever really use one type of “make a fade out” cue, and then different cues to tweak the length – which are also useful elsewhere – and another set for naming. I've found that a set of very simple tools without dialogues allow the user to cover all possibilities rather than spend ages developing complex scripts that have to second guess all possible eventualities.

Rich

On 18 Jun 2025, at 16:45, Mike Stephens <mkstep...@gmail.com> wrote:

Thanks Rich. I found an error my end which was stopping that working. I can now replicate what you have replicated. 

What would I need to do to create one relative fade out cue which sits outside of the group stack. So I therefor don't end up with a fade added to each group? So a relative fade on Outer Group which stops audio once complete. 

Mike. 

--
Contact support anytime: sup...@figure53.com
User Group Code of Conduct: https://qlab.app/code-of-conduct/
 
Instagram: https://www.instagram.com/Figure53
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.
Reply all
Reply to author
Forward
0 new messages