Hi.I have a small problem with a observable, related with the name of the selected pattern and the sequence disordered.I am using the following function for observables:
function section_name( song )
song = renoise.song()
local function name()
if song.sequencer:sequence_section_name( song.selected_sequence_index ) ~= 'Untitled Section' then -- avoid default rename 'Untitled Section'
vb.views['PMSS_TF_SEC'].text = ( "%s" ):format( song.sequencer:sequence_section_name( song.selected_sequence_index ) ) -- vb.views name section (renoise --> tool)
end
vb.views['PMSS_TF_PATT'].text = ( "%s" ):format( song.patterns[song.selected_sequence_index].name ) -- vb.views name pattern (renoise --> tool)
--print('ssi:', song.selected_sequence_index )
vb.views['PMSS_TX_NUM'].text = ( "%s" ):format( song.selected_sequence_index ) --vb.views number pattern sequence (renoise --> tool)
end
song.selected_sequence_index_observable:add_notifier( name ) -- _observable notifier selected pattern
song.sequencer:sequence_section_name_observable(song.selected_sequence_index):add_notifier( name ) -- _observable name section (renoise --> tool)
song.patterns[song.selected_sequence_index].name_observable:add_notifier( name ) -- _observable name pattern (renoise --> tool)
end
renoise.tool().app_new_document_observable:add_notifier( section_name ) -- document_observable function
If the sequence is ordered, the function does not return any errors.But if the sequence is disordered, selecting the last pattern returns an error. If the sequence is very disordered, it can return some error when selecting the penultimate pattern or earlier. The typic error:
***.\tools/tool_02.lua:17: attempt to index field '?' (a nil value)
*** stack traceback:
***.\tools/tool_02.lua:17: in function <.\tools/tool_02.lua:13>
This error is caused by the line:
vb.views['PMSS_TF_PATT'].text = ( "%s" ):format( song.patterns[song.selected_sequence_index].name )
Related with this:
song.sequencer:sequence_section_name_observable(song.selected_sequence_index):add_notifier( name )
Having the sequence disordered, returns unexpected errors. I can not find a way to solve it. Please, help!
Theme aside. Can you provide me with a function that orders the entire sequence of patterns forcefully? (the same of Organize/Flatten Sequence (Remove Repeats), in Pattern Matrix). I used ç
- song.sequencer:sort() or
- song.sequencer.keep_sequence_sorted = true
But they do not serve to sort the whole sequence.
Thanks!!!