[SOLVED] How to export Renoise Native Device Preset XML and load it back again?

so i have this and have had it for years - a way to load a PPG V2 XML as a preset. but now i wanna also do the same preset storing within a script for Native Devices. But…

But I just can’t figure out how to get the XML (which i just save from the terminal):

>>> oprint (renoise.song().selected_track.devices[2].active_preset_data)
<?xml version="1.0" encoding="UTF-8"?>
<FilterDevicePreset doc_version="13">
  <DeviceSlot type="SendDevice">
    <IsMaximized>true</IsMaximized>
    <SendAmount>
      <Value>0.0</Value>
    </SendAmount>
    <SendPan>
      <Value>0.5</Value>
    </SendPan>
    <DestSendTrack>
      <Value>0.0</Value>
    </DestSendTrack>
    <MuteSource>false</MuteSource>
    <SmoothParameterChanges>true</SmoothParameterChanges>
    <ApplyPostVolume>true</ApplyPostVolume>
  </DeviceSlot>
</FilterDevicePreset>

to do anything but output this error, when i try to load it with

if s.selected_track.devices[checkline].name=="#Send" then 
  s.selected_track.devices[2].parameters[2].show_in_mixer=true
renoise.song().selected_track.devices[2].active_preset_data="Presets/PakettiSend.xml"
else end

i get this error:

*** exception: 'Failed to parse a memory XML file (^
*** )!'
*** stack traceback:
***   [C]: ?
***   [C]: in function '__newindex'
***   [string "do..."]:22: in function <[string "do..."]:9>
***   ./loaders.lua:230: in function 'loadnative'
***   ./loaders.lua:301: in function <./loaders.lua:301>

PakettiSend.xml (500 Bytes)

what should i do? how is this properly done?

ok, it seems that the problem is that it cannot load an xml file directly, but can read the contents of the xml if they’re loaded into a variable.

function read_file(path)
    local file = io.open(path, "r")  -- Open the file in read mode
    if not file then
        error("File not found: " .. path)
    end
    local content = file:read("*a")  -- Read the entire content of the file into a string
    file:close()
    return content
end

  if s.selected_track.devices[checkline].name=="#Send" then 
  s.selected_track.devices[2].parameters[2].show_in_mixer=true
  local xml_file_path = "Presets/PakettiSend.XML"

-- Read the XML data from file
local xml_data = read_file(xml_file_path)
renoise.song().selected_track.devices[2].active_preset_data=xml_data
else end

seemed to work

1 Like