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"

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?