gen loadbang magic
so i made a "loadbang" in gen a while ago, but the way that it works is kind of black magic to me. this is fine, except that i don't want a ton of my patches to be made inoperable if cycling74 updates gen in some way that makes this not work.
can anyone tell me why this works? does gen initialize all constants as 0 first, and then change them to whatever you had set? is this something that could change in the future? also, perhaps a better question, does anyone know a better method to get a "loadbang" in gen? thanks!
No, constants get initialized at whatever value they have. You're getting the spike because of the interaction between latch and delay, both of which have some internal state. (By the way, you can initialize that internal state with the @init attribute, e.g. [latch @init 74] and [delta @init -1]).
Here's a much easier way of getting a kind of "loadbang" -- and it also gives you a way to retrigger it (by sending the "loadbang 1" or "reset" message to the gen~):
If you are doing codebox stuff, this is a common pattern:
History loadbang(1);
if (loadbang) {
// do initialization here
loadbang = 0;
}
this is almost a year late, but thanks for this! this is way simpler than what i had, and also showed me some new tricks