How to run python scripts to perform Channel rack and Mixer actions?

Discuss how to use FL Studio

Return to “FL Studio Users Forum (Looptalk)”

Forum rules
Please read them here.
[You can only see part of this thread as you are not logged in to the forums]
Jimmyhd
Sun May 10, 2026 4:06 am

x

How to run python scripts to perform Channel rack and Mixer actions?

I have this python code i've created here that will go through all the channels in the rack, and turn the volume of all of them down until they don't peak past 12db. (This is to automate some of my gainstaging process).

Code: Select all

# name=Pre-Gainstage Device (Starter)
import channels
import mixer

DEFAULT_VOL = 0.78  # 78% default volume
MAX_PEAK_DB = 12.0  # Maximum allowed peak in dB
TARGET_DBFS = -12
TARGET_PEAK = 10**(TARGET_DBFS / 20)

# 1. Set all channels to default volume
num_channels = channels.channelCount()  # get total number of channels


for ch_index in range(1, num_channels + 1):
    try:
        channels.setChannelVolume(ch_index, DEFAULT_VOL)
        current_fx_track = channels.getTargetFxTrack(ch_index)
        mixer.setTrackVolume(current_fx_track, 1.0)
        curr_peak = mixer.getTrackPeaks(current_fx_track, "PEAK_LR")
        gain = TARGET_PEAK / curr_peak
        if(curr_peak > TARGET_PEAK):
            new_vol = DEFAULT_VOL * gain
            channels.setChannelVolume(ch_index, new_vol)
    except Exception as e:
        print(e)

print("finished")


But I don't see exactly how to run this script in fl studio. I follow the instructions here: https://www.image-line.com/fl-studio-le ... 0window%3A which say to move the script to the appropriate folder and set it as the midi device then open the script output window. But I just get this error saying "Operation unsafe at this time"

Image

It seems weird to be running a python script for the channel and mixer rack as a "Midi device" though, so I think I might be going wrong somewhere with this. Anyone able to provide insigt?

Return to “FL Studio Users Forum (Looptalk)”