Instrument Autocapture On Trackchange?

is it possible to call instrument autocapture automaticalley whenever the active track is changed? i think it might have something to do with notifers but up to now i havent managed to fully understand them.

Notifers are used to trigger a function. When you attach a notifier to an observable property (in this case the track index changing), you state the function you want to attach.

The following code will do what you want:

--declare function capture_inst()  
  
local function capture_inst()  
 renoise.song():capture_instrument_from_pattern()  
end  
  
--add notifier that will fire off the above function --capture_inst()   
  
renoise.song().selected_track_index_observable:add_notifier(capture_inst)  
  
  

You also need to remove notifiers manually. If you want/ need to do this for your script:

  
--remove notifier (capture_inst)  
  
renoise.song().selected_track_index_observable:remove_notifier(capture_inst)  

Also a tip worth noting, when testing/ debugging your script and you find notifiers unexplainably attached and still firing, you can reset them for all tools by “reload all tools”.

wow. thank you very, very much for your help, ledger!

No probs,

notifiers are really useful, but can be a bit tricky to handle, you may also need to test for them sometimes before removing one with has_notifier:

  
if renoise_observable_property:has_notifier(my_function) then  
 renoise_observable_property:remove_notifier(my_function)  
end  
  

for the above generic example renoise_observable_property refers to renoise.song().selected_track_index_observable

and my_function refers to capture_inst()