I am trying to use the renoise.Document API for saving song.tool_data, which seems pretty convenient! However, I cannot seem to unserialize/load it (as a document).
I have a bunch of objects/nodes in a DocumentList. Any pointers on how to load them from the xml string, using the from_string() method? Need I create some object as a prototype for the list? (I’ve tried that also, I think)
Here is the code, in which the second function doesn’t work.
Summary
function App:update_song_tool_data()
local rhythms = renoise.Document.DocumentList()
local main_doc = renoise.Document.create("Arranger") {
Rhythms = rhythms
}
for rhythm_idx, rhythm in ipairs(self.rhythms) do
rhythms:insert(rhythm)
end
renoise.song().tool_data = main_doc:to_string()
end
-- DOESN'T WORK
function App:load_song_tool_data()
local rhythms = renoise.Document.DocumentList()
local main_doc = renoise.Document.create("Arranger") {
Rhythms = rhythms
}
main_doc:from_string(renoise.song().tool_data) -- !!!!!
-- print(main_doc:to_string()) -- yup. didn't unserialize
end
XML string:
Summary
<?xml version="1.0" encoding="UTF-8"?>
<Arranger doc_version="0">
<Rhythms>
<Rhythm type="lua_class:Rhythm">
<rhythm>1.0</rhythm>
<length>32</length>
<linerot>0.0</linerot>
<steprot>0.0</steprot>
<inst_index>1.0</inst_index>
<note_value>48</note_value>
<track_index>1.0</track_index>
<pattern_index>1.0</pattern_index>
</Rhythm>
<Rhythm type="lua_class:Rhythm">
<rhythm>2</rhythm>
<length>32</length>
<linerot>0.0</linerot>
<steprot>0.0</steprot>
<inst_index>2</inst_index>
<note_value>48</note_value>
<track_index>2</track_index>
<pattern_index>1.0</pattern_index>
</Rhythm>
</Rhythms>
</Arranger>