Programmatically set trim (vs level)

167 views
Skip to first unread message

James Houston

unread,
May 22, 2025, 2:59:22 PMMay 22
to ql...@googlegroups.com
Copied from my Reddit post:

Hello! I'm a new user and I'm running sound for a burlesque/aerial show with incoming tracks of wildly varying volume. I found the "Level Playing Field" cookbook item https://qlab.app/cookbook/level-playing-field/ and I appreciate how easy it's making this part of the job! This particular script uses the setLevel applescript API call, but I'd love it if I could adjust the trim instead, that way when I use fades, I can rely on the music track itself to play nice with everyone's ears instead of duplicating that work on a fade cue.

Am I thinking about this correctly?

For now, I'm going to manually move the script-generated level to the trim value, but on a larger show it would be nice to skip that step.

FL K

unread,
May 22, 2025, 7:58:32 PMMay 22
to QLab
Hi James,

I wanted this for years lol... not sure if it is or has ever made it onto the list anywhere near the top though *sigh*. I am a big fan of using Trim for overall adjustments (similar to a gain knob on a mixer), and use levels mainly on unity or -inf, or build and dips, but from a similar jump-off point, hence having the trim more accessible through osc and script would be ace :).

Cheers,
Freddy

Chris Ashworth

unread,
May 23, 2025, 10:45:00 AMMay 23
to James Houston, ql...@googlegroups.com
Hi there James!

I’ve added your feedback to our issue tracker about adding API support for setting trim values.  I agree it makes sense to add it.

Best,
Chris

James Houston

unread,
May 24, 2025, 2:46:35 AMMay 24
to QLab
Chris, 

Thank you for accepting the feedback! 

I've enjoyed learning the tool and am starting to get the hang of things for my basic show. Curtain is tomorrow and I'm thrilled to have more automation this time around.

Have a great weekend,
James

FL K

unread,
Oct 15, 2025, 3:57:28 AMOct 15
to QLab
Hi Chris/lovely folks at Figure 53,

Just following up on this one since the audio engine was recently touched - any rough horizon on this one?

Cheers and thanks,
Freddy

Rich Walsh

unread,
Oct 15, 2025, 4:19:03 AMOct 15
to ql...@googlegroups.com
You could also get round if for now by replacing this line:

eachcue setLevel row 0 column 0 db theadjustment


With:

repeat with i from 1 to audio input channels of eachcue

eachcue setLevel row i column 0 db theadjustment

end repeat


This would put the “trim” on the master levels for each channel, which you shouldn’t ever need to fade as you can fade either the output faders or the input-to-output crosspoints instead. (By contrast, you are highly likely to want to fade the master level fader…)

Rich

Paul

unread,
Oct 15, 2025, 2:40:49 PMOct 15
to QLab
In situations like this I prefer to normalise the files outside of Qlab then whatever edits to levels/trim can be purely artistic decisions rather than worrying about the level in relation to other files.
Using ffmpeg it's quick and simple to batch process a whole directory of audio files using this script, which has the advantage that it converts to WAV files, you can specify the sample rate and the loudness target. Wave files generally  give more consistent playback in Qlab (mp3s have a lot of variation)

#!/bin/sh


# normalise audio files using ffmpeg batch process

# see https://ffmpeg.org/ffmpeg-filters.html#loudnorm


## Settings

# set the rate for output audio (eg 44100, 48000, 96000)

rate=44100

# set the integrated loudness target

#  loudness target range is -70 to -5 (about -15dB is a good level, EBU is -23dB)

ilt=-15


## program usage

prog=`basename $0`

usage() { echo "$prog - normalise audio files\nUsage: $prog *.wav *.mp3"; exit 0; }

if [ $# -eq 0 ]; then usage; fi


## process input files

for input

do

    # generate output file name, based in input name

    outfile=${input/\.[a-z]*/_norm.wav}

    # normalise the file using ffmpeg

    ffmpeg -v error -i "$input" -af loudnorm=i=$ilt,aresample=$rate -ac 2  "$outfile" && echo $outfile

done


FL K

unread,
Oct 30, 2025, 8:29:47 AM (24 hours ago) Oct 30
to QLab
Hi Rich and Paul,

Indeed, these work-arounds I have used in the past, I just think that as mentioned above, being able to control trim programattically/via knobs provides a more elegant solution going forward (with e.g. levelling the playing field, where indeed I am using the L+R Crosspoints at the moment to avoid using the main Level fader for this).

Cheers,
Freddy
Reply all
Reply to author
Forward
0 new messages