Norns: scripting

Great, I didn’t know I could use the same metro, it’s working now. Thanks !

Metro question: how can I trigger a function on ticks instead of steps?

I’m trying to change step rates so that I can use 32n, 64n, or different subdivisions such as triplets or dotted notes. Since each step has 6 ticks, I figured I’d just need to get the correct modulo for each interval. Correct?

I tried adding a callback to /lib/beatclock.lua but it doesn’t seem to work.

Beatclock has a steps per beat argument that I think should work out?

1 Like

Yeah that’s what I was looking for! Thanks :slight_smile:

1 Like

does anyone have suggestion on a good way to test midi out. I don’t have any midi devices, but want to make sure midi out works for the scripts I’m developing.

post in code review and/or have a friend test it for you?

3 Likes

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.

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)

2 Likes

That took care of it! Thanks

Oops sorry (& 20 characters)

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:

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.

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

3 Likes

Bingo! Thanks, Justmat

1 Like

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.

1 Like

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.

8 Likes

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.

Is there a way to execute run script via ssh?
(i.e. whatever magic that the Maiden ‘run script’ button does)

Working in a text editor and sftp right now and I have to reach over and click buttons everytime I want to re-load the script I’m working on. Gets tiresome after the 100th time.

2 Likes

options

  1. run matron directly instead of using the websocket wrapper, call script.load(foo) directly from the REPL.

  2. roll a little utility with readline and nanomsg to act as a local websocket endpoint.

but no, there’s no utility to make this easier at the moment. would be a nice addition.

1 Like

What @zebra said but I believe the function is norns.script.load(...) - at least that is what maiden is using.