r/Reaper • u/Equivalent-Zone9475 • 32m ago
discussion Curiosity Project: WARNING - Stupid
Out of curiosity, I asked Google to make a script which adds tracks, each with an equalizer set for each individual Hz in the audible frequency spectrum and rejecting all others. It worked with limited success. Google provided the following script which prompts for frequency step size and Filter Bandwidth: Create_Frequency_Tracks.lua
I added 2000 tracks on my i9 13900k/64GB DDR5 6400 without crashing but the Equalizer, ReaEQ, is wonky. Best of luck and try not to crash Reaper or your system.
-- Create tracks equalized for each Hz across the audible spectrum
-- u/version 1.0
local START_HZ = 20
local END_HZ = 20000
-- WARNING: Setting STEP_HZ to 1 creates 19,981 tracks and will likely freeze/crash REAPER.
-- Keep at 100 or 500 for testing, then lower carefully.
local STEP_HZ = 100
local BANDWIDTH_OCT = 0.05 -- Very narrow Q/bandwidth to isolate the frequency
function Main()
-- Prompt user for confirmation and step size
local retval, user_input = reaper.GetUserInputs(
"Frequency Spectrum Track Generator",
2,
"Step Size in Hz (1 = 19981 tracks!):,Bandwidth (Octaves):",
tostring(STEP_HZ) .. "," .. tostring(BANDWIDTH_OCT)
)
if not retval then return end
local step_str, bw_str = user_input:match("([^,]+),([^,]+)")
local step = tonumber(step_str)
local bandwidth = tonumber(bw_str)
if not step or step < 1 or not bandwidth or bandwidth <= 0 then
reaper.ShowMessageBox("Invalid input values.", "Error", 0)
return
end
local total_tracks = math.floor((END_HZ - START_HZ) / step) + 1
if total_tracks > 1000 then
local confirm = reaper.ShowMessageBox(
"You are about to create " .. total_tracks .. " tracks with active FX.\nThis may freeze or crash REAPER. Continue?",
"High Track Count Warning",
4 -- Yes/No
)
if confirm ~= 6 then return end -- 6 is Yes
end
-- Begin Undo Block and freeze UI for speed
reaper.Undo_BeginBlock()
reaper.PreventUIRefresh(1)
local track_idx = reaper.CountTracks(0)
for freq = START_HZ, END_HZ, step do
-- 1. Insert new track at the end of the project
reaper.InsertTrackAtIndex(track_idx, false)
local track = reaper.GetTrack(0, track_idx)
-- 2. Name the track
reaper.GetSetMediaTrackInfo_String(track, "P_NAME", tostring(freq) .. " Hz", true)
-- 3. Add ReaEQ to the track
local fx_idx = reaper.TrackFX_AddByName(track, "ReaEQ", false, -1)
if fx_idx >= 0 then
-- Configure Band 1 as a Band-Pass filter (Type 8 in ReaEQ)
-- Note: ReaEQ parameters are normalized (0.0 to 1.0)
-- Set Band 1 Type to Band Pass (Normalized value for Band Pass)
reaper.TrackFX_SetNamedConfigParm(track, fx_idx, "BANDTYPE0", "8")
-- Calculate normalized frequency for ReaEQ (Logarithmic scale 20Hz - 20kHz)
-- Formula: log(freq / 20) / log(20000 / 20)
local norm_freq = math.log(freq / 20.0) / math.log(1000.0)
norm_freq = math.max(0.0, math.min(1.0, norm_freq))
-- Param 0: Band 1 Freq | Param 1: Band 1 Gain | Param 2: Band 1 Bandwidth
reaper.TrackFX_SetParamNormalized(track, fx_idx, 0, norm_freq)
reaper.TrackFX_SetParamNormalized(track, fx_idx, 2, bandwidth / 4.0) -- Max BW is 4 octaves
-- Disable unused default bands (Bands 2, 3, and 4) so they don't interfere
reaper.TrackFX_SetNamedConfigParm(track, fx_idx, "BANDENABLED1", "0")
reaper.TrackFX_SetNamedConfigParm(track, fx_idx, "BANDENABLED2", "0")
reaper.TrackFX_SetNamedConfigParm(track, fx_idx, "BANDENABLED3", "0")
end
track_idx = track_idx + 1
end
-- Restore UI and close Undo Block
reaper.PreventUIRefresh(-1)
reaper.TrackList_AdjustWindows(false)
reaper.Undo_EndBlock("Generate Frequency Spectrum Tracks", -1)
end
Main()