► Api Changes + Fixes In 2.6 Rc2

Some last minute changes for 2.6:

Added:

  • renoise.app():prompt_for_path(dialog_title) -> [valid path or empty string]

  • Pattern Line notifiers as needed by tools that visualizes pattern data:

  
-- Check/add/remove notifier functions or methods, which are called by Renoise   
-- as soon as any of the pattern's lines have changed.   
-- The notifiers are called as soon as a new line was added, an existing one   
-- was cleared, or existing ones changed somehow (notes, effects, anything).   
--  
-- One argument is passed to the notifier function: "pos", a table with the   
-- fields "pattern", "track" and "line", which define where the change has  
-- happened:  
--  
-- function my_pattern_line_notifier(pos)  
-- -- check pos.pattern, pos.track, pos.line (all are indices)  
-- end  
--  
-- Please be gentle in the notifiers, don't do too much stuff in there.   
-- Ideally just set a flag like "pattern_dirty" which then gets picked up by  
-- an app_idle notifier: Line change notifiers can be called hundreds of times  
-- when for example simply clearing a pattern.  
-- If you are only interested in changes that are made to currently edited   
-- pattern, dynamically attach and detach to the selected pattern's line   
-- notifiers by listening to "renoise.song().selected_pattern_observable".  
  
[added RC2] renoise.song().patterns[]:has_line_notifier(func[, obj])  
 -> [boolean]  
  
[added RC2] renoise.song().patterns[]:add_line_notifier(func[, obj])  
[added RC2] renoise.song().patterns[]:remove_line_notifier(func[, obj])  
  

Please do not ignore the note about “be gentle in the notifiers”. Wrongly used they will easily be a big problem and lag any pattern operations in Renoises main editor, the Pattern Editor.

To avoid such a lag, prefer doing real update stuff in one batch in idle, like:

  
function line_changed_notifier(pos)  
 -- a line changed that we are displaying, refresh the UI later on  
 refresh_ui = true  
end  
  
-- then in your idle notifier:  
  
function on_idle()  
 if (refresh_ui) then  
 refresh_ui = false  
 -- pattern changed. rebuild the UI which represents the pattern   
 end  
end  
  

Fixed:

A few coroutine related issues have been fixed. Like it was not possible to remove a notifier in a Lua thread that was added by the main thread. Also fixed a possible crashes crash when creating dialogs from within Lua threads.

Unfortunately I’ve noticed a bit too late that listening to changes for the currently edited pattern needs a renoise.song().selected_pattern_observable, but we only had a ‘renoise.song().selected_pattern_index_observable’ so far. Subtle, but important difference. So I’ve quickly added one now and silently updated RC2.

Here’s an example on how to use it (copy and paste into the testpad.lua):

[luabox]
– selected_pattern_lines_changed

function selected_pattern_lines_changed(pos)
rprint(pos) – test
end

– attach_to_selected_pattern

local attached_pattern = nil

function attach_to_selected_pattern()
if (attached_pattern) then
attached_pattern:remove_line_notifier(selected_pattern_lines_changed)
end

attached_pattern = renoise.song().selected_pattern
attached_pattern:add_line_notifier(selected_pattern_lines_changed)
end

– attach_to_song

function attach_to_song()
renoise.song().selected_pattern_observable:add_notifier(attach_to_selected_pattern)
end

– main

attach_to_song()
attach_to_selected_pattern()
[/luabox]

If you get an error (renoise.song().selected_pattern does not exist) with the example, then please download RC2 again from the backstage. Sorry for the fuzz…

Re-downloaded, ran the test, clicked around, occasionally get:

  
*** std::logic_error: 'The given notifier was not added.'  
*** stack traceback:  
*** [C]: in function 'remove_line_notifier'  
*** TestPad.lua:14: in function <12><br>
<br>```

<br>
<br>
Not sure what the code snippet you posted does, though.</12>

Have you exectuted the script more than once, then changed a pattern? The code above does not handle this, so this is expected.

The snippet adds a notifier which will be called as soon as any pattern line in the currently edited pattern changed. This will be useful for tools which visualize pattern data, like the ticky roll, Duplex’s step sequencer and so on…

Yes, I did execute the script more than once. Thanks for the explanation.