[SOLVED] How to load a Device preset by name instead of number slot?

this is also about XRNT…
So I have this stuff

>>> rprint (renoise.song().selected_track.devices[2].presets)
[1] =>  Init
[2] =>  #SendPakettiInit
[3] =>  Init
[4] =>  Init2
>>> renoise.song().selected_track.devices[2].active_preset = 2

and i’d like to load the #SendPakettiInit of this #send device. but i don’t want to load it by saying “2”, because maybe the slot “2” is not that at all.

How do i make sure that instead of loading “some” preset that happens to be in preset slot, i always load “#SendPakettiInit”, please?

also, how can I load a XRNT? I have no way of changing the Send device settings since i can’t control “Keep Source” / “Mute Source”, only the Amount, Panning and Receiver. Need better control. my solution was to create a preset, but i need to be able to load it. but answering both quetsions would be amazing.

Maybe iterate over the presets and look for a string match on the name. Then use the associated index to assign active_preset.

1 Like

thanks, i eventually got it going!

What did you do?

modified my “what to do if #Send is added” to this:

  if s.selected_track.devices[checkline].name=="#Send" then 
  s.selected_track.devices[2].parameters[2].show_in_mixer=true
  -- This loads "#SendPakettiInit"
-- Your target preset name
local targetPresetName = "#SendPakettiInit"

-- Retrieve the list of presets for the selected device on the selected track
local presets = renoise.song().selected_track.devices[2].presets

-- Iterate through the list of presets
for index, presetName in ipairs(presets) do
  -- Check if the current preset name matches the target
  if presetName == targetPresetName then
    -- If a match is found, set the active_preset to the index of the found preset
    renoise.song().selected_track.devices[2].active_preset = index
    
    -- Optionally, print a message or do something else
    print("Preset '" .. targetPresetName .. "' found and activated at slot " .. index)
    
    -- Since the preset is found and activated, break out of the loop
    break
  end

… basically asked chatgpt.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.