Norns: scripting

norns

#363

Any one else get a constant tone coming out of their Norns when loading the Kria Midi script? Also wondering what I need to do to get mp_ack to send midi out.


#364

pretty sure that’s because it has this at the start

engine.name = "TestSine"

i think you could comment that out and be just fine.
(I guess I should probably test that advice, but can’t do that for a bit)


#365

That took care of it! Thanks


#366

Oops sorry (& 20 characters)


#367

Can anyone point me to a technique or example of slewing values? I’m thinking in midi space especially slewing cc values over time. :pray:


#368

I’m trying to stop a MIDI loop with a keypress and restart the loop with the same keypress. The following function does stop the loop, but each successive keypress simply advances one note at a time from the point where it stopped.

k_pos = 0

function key(n,z)
if n == 3 then
if k_pos == 0 then
clk:start()
k_pos= 1
elseif k_pos == 1 then
clk:stop()
k_pos = 0
end
end
end

How should this be handled? Thanks.


#369

The key function gets called on both press and release. It sounds like you just need to filter out the release.

so, instead of if n == 3 then you could do if n == 3 and z == 1 then


#370

Bingo! Thanks, Justmat


#371

metro questions!

I’d like to make a delay() or wait() function but not real sure what to do.

As an example - On a specific user interaction I’d like to have a function fire x amount of times with a 1 second interval. So with Arduino (that I know pretty well) I could just use a delay(1000). Here on norns I need a metro, but this seems different than doing a callback function every tick of the metro.


#372

yes, you’ll have to indeed create a metronome and stop it after X runs (see count parameter to metro.init). or create a bunch of oneshot metros running one after another. there’s no delay() as such because it will block the lua interpreter from doing other work (handling messages, etc.).

i’m currently working on a clock module that uses coroutines for concurrent wait operations and it will provide a more intuitive way to do the above.


#373

FWIW - I tried this but was getting -1 for count so I must’ve been doing something wrong. I’ll have to look at that again.

I ended up making my own counter in the metro callback and then stopping the metro as you suggest. I wasn’t sure at first if it was OK to stop the metro from within the callback, but that seems to work just fine.