How To Always Load With Autofade On?

hi, how could i always load a wavefile with autofade on, to a new instrument box?

i would select an empty instrument box entry, i would click on a sample in the disk browser (or drag a sample into the instrument box from outside Renoise… and Renoise would load it… with Autofade automatically set to on?

How would one do that, please?

Natively there is no solution. With the API i would set an observable on Renoise Instrument section, create a blueprint from the current loadout (which instruments are existing now and which samples) and scan for changes if it gets fired, then apply autofade on the sample that got added to the session.

So far I seem to have a form of understanding that goes roughly like this:
There can be added keybinds which run functions, which are fired everytime the keyboard is run. it’s a one-stop shop, press a button, function runs and ends.
then there’s this, far more obscure “run always” type thing which seems to be run when Renoise starts. This of course dies the minute you restart renoise and it tries to set locals or call locals that access - firing an error when the script is run and it discovers that no song exists. I don’t really know how to make them go, so to speak, without shooting errors and forcing me to ditch them.

now, i’m not sure, but it seems that the notifiers and observables are better called via a GUI - i.e. then you have a button that toggles something on, and that something which has been toggled on, can be toggled off. the user knows that okay, now the button is pressed, now it’s not – and, as expected, a notifier is created which fires a function when an observable item changes. obviously a notifier to run a function is created when the button is pressed - and it will stay as a notifier, tied to that observable, ready to be run when that observable item changes.
and the button press in the gui will then check if there’s a notifier, and remove it. the first button press will of course check and remove a notifier and then add a notifier, to make sure there’s only 1 notifier by that name (functionname), for that observable. so far, so good.

now, here’s the thing i don’t get.

when you don’t use a gui, and instead use keyboard shortcuts. the only visibility is that when a mode is on, the show_status says “this is on” or then “this is off”. what i really do not grasp is, is the concept to actually put the notifier creation into the add_keybinding directly? and then when the function is run, it does exactly what it should, i.e., what it does?

so far i have been using a keybinding to call a function, which does a few things, then clears&adds a notifier to a specific observable, which then runs a function (or, more like it, doesn’t, at all), and then i hope for the best. it seems to me that an instrument change observable for autofade would be one of those “autoexec.bat” type things, which shoot those at me on start of renoise. but maybe not.

i just have a really hard time figuring out how to fit this whole notifier thing into what i kind-of know how to manipulate, after so much help from everyone on the forums and elsewhere.

I suggest this approach:

  • Write functions as you normally do (as if they were called by an event handler)
  • Create functions to attach / detach observables
  • Create a menu entry for the autoseek enabled load
  • Menu entries can have state indicators (a little tick appears adjacent if enabled)
  • Test via this method
  • Create a ‘startup’ function that calls all the others and test this thoroughly
  • Just call the startup function at the end of your code returns nil if it doesn’t exist, you however cannot put a condition against it.
You do can assure yourself that is being read as soon as it is available, the following method allows you to set the new document observable and read as soon as it is available.
That is the best method to have the contents as soon as possible (you can put these on top of your main.lua file):

function new_document()  
 local song =" is available")  
--Fired if the song is being changed for a loaded one or a new document  
if not (renoise.tool().app_new_document_observable:has_notifier(new_document)) then  
end will always contain table-data at that very moment. Even if renoise is started from scratch.

Thing is, I’ve not been able to figure out how to “read current instrument table state” and “realize something has changed”, and then trigger a sample. I’m not sure how to proceed with this.