Norns: scripting

i would love to see this one too. I think doing a random jukebox is a great way to understand tables, strings etc…
share possibly?

thank you


Trying to send some midi back out (echo) when a note is received.

local midi_data = {144, note, velocity}

Error: lua: /home/we/dust/scripts/okyeron/hello_gong_osc.lua:107: attempt to index a nil value (global ‘Midi’)

I don’t understand where a nil value is happening. Any pointers?

EDIT: I’m apparently doing something stupid, but haven’t figure out what just yet :stuck_out_tongue:

Yes, would be happy to! I had big plans to add extra bells and whistles, but I think I need more time to absorb all the info from the 2nd study. I’ll share what I have later tonight or tomorrow.

OK - I got myself working with midi.send(dev,data) I had to define a variable for the device in midi.add(dev) and include that in my midi.send (the nil value was because I wasn’t picking up a value for dev)

Question: Where do these “status” codes for midi events come from?

norns.midi.event = function(id, data)
  status = data[1]
  data1 = data[2]
  data2 = data[3]
  if status == 144 then
    note_on(data1, data2)
  elseif status == 128 then

The earthsea script (snippet above) has a note-off code of 128, but my midi controller sends note-off as 144 with velocity 0 (same code as note-on)

The numbers are from MIDI standard itself! A note_on with velocity = zero is often used as a note-off (I guess the code is easier?). Thus: note_on(pitch, 0) is the same as note_off(pitch).

You could change the line note_on(data1, data2) to:

if data2 == 0 then note_off(data1)
else note_on(data1, data2) end

Which should cover the case you mention

1 Like

Just a quick word of warning. If anyone comes across scripts in dust which assign values to anything in the norns module (like this snippet does) please flag it - as it is most likely the wrong way to do something. The norns module contains the low level glue where C-level hardware drivers are exposed to lua - changing things in the norns module will likely cause other scripts to break.

In the case of midi the proper way to define event handlers is shown in earthsea, specifically:

…looking at the dust repo I see that the hello_gong script is still using the (now internal) midi api (which we need to fix).


Aha - Thanks! I hadn’t found a list that had Binary, hex and dec versions of the status byte. That helps a bunch.

I ended up using this in a test script

if data[1] == 144 and data[3] > 0 then
  note_on(data[2], data[3])
elseif data[1] == 144 and data[3] == 0  then

But your example is a bit cleaner.

Great to know. Thanks!

I had been trying to get midi.send working in hello_gong so that’s where I copy/pasted that part. Although I ended up using the earthsea script to get my midi send working.

I’ve got a Livid Block grid controller and it needs to have the midi note sent back to it for the LEDs to light up. I’m guessing this would be similar for other controllers like launchpad or apc40.

FWIW here’s what I added:

local function note_on(note, vel)
   if nvoices < 6 then
     midi.send(midi_device, {144, note, vel})
     --engine.start(id, getHz(x, y-1))
     engine.start(note, getHzET(note))
     nvoices = nvoices + 1

local function note_off(note, vel)
  midi.send(midi_device, {144, note, 0})
  nvoices = nvoices - 1

midi.add = function(dev)
   print('earthsea: midi device added',,
   dev.event = midi_event
   midi_device = dev

metro is in next week study, but until then see playfair's init, or:

  t = metro.alloc()
  t.count = -1
  t.time = 0.5
  t.callback = function()
1 Like

@shreeswifty @babatunde – Updated my Oblique Strategies script this morning to improve the linear scroll idea I had for this (you can see it in action around the 20-second mark in the video below).

If you’re interested in checking it out, I created a public gist for the script on Github:
Oblique Strategies for Norns

Keep in mind that, while the script is fully functional, the code could definitely be improved (I’m still pretty new to Lua and coding in general)! If you have any ideas for improvements, I’m all ears.


this is awesome!

PM winging your way :+1:

1 Like

Oh man… there’s probably something wrong with me that the first thing I thought of looking at your code was… Hmmmm - what if we could access a large number of Oblique Strategies (or other interesting data) from a mySQL database?

which led me to…



I want to do Angus Maclise’s YEAR or book of Days so when you start Norns it loads what day it is^google|twcamp^serp|twgr^author

according to Angus of course :slight_smile:

1 Like

After figuring out midi.send last night I went ahead and tried to fully-midi enable the earthsea script so the pattern stuff would work from my Livid Block midi controller.

Here’s my work in progress. I’m not sure everything is working properly yet. Not sure how other controllers map note numbers so YMMV.

earthsea midi for Block

Thanks for this example. Could you direct me to where I could find an example of a poll in a lua script? I know how to create one in the CroneEngine, just not how to access it in lua.

this is a confusing example (because it’s an array of polls) but:

i’ll explain polls in week 5’s study

1 Like

I saw local TRACKS = 4 up at the top of the code and had a brief moment of excitement about more MLR tracks … is the CPU powerful enough to handle this?

we’re working on it, and changing the TRACKS var will not auto-magically increase the number… there’s more plumbing beyond that


Hey, it’s fathers day: if I can be a father, anything is possible.


Thanks for directing me to that snippet. It helped and I have my poll working now. Thank You! Looking forward to the next few norns studies.