Add Notifier For Any Pattern Editing

I need to get info about note or instrument just edited.

How can I do this ?

song.patterns[song.selected_pattern_index]:add_line_notifier(pattern_readout_function)

Do note that the function is fired for every change (and possibly undo), so use wisely.

  
renoise.song().patterns[renoise.song().selected_pattern_index]:add_line_notifier(function(obj)  
  
end)  
  

I get this error

unknown property or function ‘add_notifier’ for an object of type ‘Pattern’

What’s wrong ?

You need to define the function name only, no function definition.
renoise.song().patterns[renoise.song().selected_pattern_index]:add_line_notifier(my_function)

the line-notifier submits one parameter which is table pos:

function my_function(pos)
print (pos.line)
print (pos.track)
print (pos.pattern)
oprint(pos)
end

Thank you :)

What to do I have to attach a notifier for all the future patterns ?

I looked for pattern_assignments_observable but I can’t understand how use it

What to do I have to attach a notifier for all the future patterns ?

This is pretty complex stuff. There are several “conditions” that you might want to check for, it really depends on what you are trying to achieve.
I guess, since we are talking about “pattern editing”, it’s realistic to expect that you want to monitor the currently edited pattern.
In such a case, it would be sufficient to track (1) the selected_pattern, and (2) the pattern_observable

(1) Will allow you to create/attach the line notifier for the current pattern when has changed due to playback or manual scrolling through the pattern list
(2) Will do the same thing, but deals with when the pattern sequence itself has changed (new pattern is inserted, removed or changed)

And like vV says, it’s important that you don’t handle the notification immediately. For example, clearing a pattern will yield hundreds of calls to your notification handler -
instead, you can raise a flag (some variable saying “line_notification_has_happened = true”) and process that one in a separate idle method.

In fact I was looking for something like this

renoise.song().patterns_observable:add_notifier(on_pattern_changes);  

Obviously I have to check if pattern has already a notifier.

Thank you