Running code only on startup


#1

I want to be able to write some code that only runs once on startup of a patch, the Axo will be connected to some other hardware via the GPIO, and I want it to be able to send only one set of instructions via the GPIO so it is a kind of initialization and synchronization for the other hardware and Axo.
Where best should the code go and are their any objects that need to be referenced for the startup event etc ?

And sort of related to the above, we know the starting of a patch can be stopped from starting automatically by holding down S1 during power up, but how do you start it ? Can this stopping and starting done through code ?

Thanks in advance..


#2

Code in the Init Code section of an object only runs once, when the object is initialised.

You may find that code here can't access I/O though, so you could write a little bit of K-Rate code that runs only when a switch Boolean variable is set true, then once it's done it's thing, sets the switch false.

a|x


#3

Patches can trigger loading a new patch (which will stop the current), using the "patch/load..." objects.
You can have a startup patch that does not do any sound, but just serves to load other patches.
If you'd stop a patch, there is nothing left that can load another patch unless you dive into firmware hacking. So better load a silent patch that loads other patches.


#4

Thanks,
I was thinking about doing it that way, I haven't learnt how to run patches on SD Card yet, so better start searching through the forum.