monome / norns

norns is many sound instruments.
http://monome.org
GNU General Public License v3.0
614 stars 144 forks source link

make metro stage settable #655

Closed catfact closed 5 years ago

catfact commented 5 years ago

(after rambling about it here https://github.com/monome/norns/issues/653)

metro.lua objects have a stage property that is automatically updated on each wakeup, and given as an argument to the lua callback. it's not user-settable.

in a nutshell, the reason is that allowing it to be user-settable leads to race conditions. these races will lead to bugs in user code.

even if races are allowed, stage number is currently protected by mutex and it seems like a bad idea to let lua thread hold the lock at any time (not just on init/start.)

one idea might be to make stage atomic (sig_atomic_t?) and read it directly at the lua callback, instead of writing it in the scripting event data.

(NB that this can easily be worked around by keeping explicit sequence state in lua.)

tehn commented 5 years ago

i really think this is going to far. the explanations on #653 are valid, the metro API is good.

if complicated behaviors are needed ie resets or different step sizes, just do that in the lua userspace.

my vote is to close this.

artfwo commented 5 years ago

+1 for closing this.