Norns: scripting

norns

#343

@nosolllution maybe add this to your midi handler so we can see what is coming in (before attempting to parse it)

for k,v in pairs(data) do print(k,v) end

kinda seems like it’s maybe sending noteon without velocity byte, pretty weird.


#344

It may also be instructive to plug the Sub37 into your computer and use a midi monitor to look at all the data being sent when the Arp is turned on.

On MacOS I use Midi Monitor. On windows maybe MIDI-OX


#345

Hi Junklight, I’m trying to setup with USB serial as well (Spotty wifi here). Can you explain the following commands? my gnu screen is messing up all my colours.’

edit 1: I see the col and row settings is to define the amount of row and columns to display. Where would i put the EXPORT TERM=… ?

edit 2: this works for ssh, but not for gnu/screen. most likely because macOS version of screen is not compiled for more colors.


#346

I think this might have been fixed by https://github.com/monome/norns/pull/658


#347

oh yes, that probably fixes it.

gotta get this update finished!


#348

@tehn, @artfwo, @zebra, @okyeron, @markeats,

Thank you for the insight and guidance! Per suggestion, lua print statement and MIDI Monitor outputs are included below.

I’m using shorthand in the print statement output below; “ERROR STATEMENT” means the identical multiline error statement in my previous post.

LUA Print

LUA CODE:

124 midi_keys.event = function(data)
125 for k,v in pairs(data) do print("k = “…k,” v = "…v) end
126 local d = midi.to_msg(data)

LUA OUTPUT: Arp rapid on / off less than one arp step:

k = 1 v = 250
ERROR STATEMENT
k = 1 v = 248
ERROR STATEMENT
k = 1 v = 176
k = 2 v = 73
k = 3 v = 64
k = 1 v = 248
ERROR STATEMENT
k = 1 v = 248
ERROR STATEMENT
k = 1 v = 248
ERROR STATEMENT
k = 1 v = 252
ERROR STATEMENT
k = 1 v = 176
k = 2 v = 73
k = 3 v = 0

MIDI Monitor

Arp rapid on / off less than one arp step:

20:05:40.149 From Moog Sub 37 Start
20:05:40.150 From Moog Sub 37 Clock
20:05:40.151 From Moog Sub 37 Control 1 Attack Time 64
20:05:40.228 From Moog Sub 37 Clock
20:05:40.270 From Moog Sub 37 Stop
20:05:40.271 From Moog Sub 37 Control 1 Attack Time 0

Arp on for ~one arp step:

19:43:11.435 From Moog Sub 37 Start
19:43:11.436 From Moog Sub 37 Clock
19:43:11.437 From Moog Sub 37 Control 1 Attack Time 64
19:43:11.622 From Moog Sub 37 Clock
19:43:11.808 From Moog Sub 37 Clock
19:43:11.995 From Moog Sub 37 Clock
19:43:12.181 From Moog Sub 37 Clock
19:43:12.368 From Moog Sub 37 Clock
19:43:12.555 From Moog Sub 37 Clock
19:43:12.741 From Moog Sub 37 Clock
19:43:12.928 From Moog Sub 37 Clock
19:43:13.115 From Moog Sub 37 Clock
19:43:13.301 From Moog Sub 37 Clock
19:43:13.488 From Moog Sub 37 Clock
19:43:13.674 From Moog Sub 37 Clock
19:43:13.861 From Moog Sub 37 Clock
19:43:13.948 From Moog Sub 37 Stop
19:43:13.949 From Moog Sub 37 Control 1 Attack Time 0


#349

I see there is an Eclipse Lua editor for MacOS. I’m curious what Mac users are using to edit scripts and work with the norns git repo?


#350

As the others posted, it’s likely a bug in how midi.lua is handling the incoming clock bytes.

I submitted a fix but it was after the last norns update went out - so still not in an official release.

If you want to fix this yourself you could edit midi.lua per these details:

Basically a bracket is missing (just before the while()) and that’s causing an issue with clock/start/stop commands.


#351

well, maiden and an ssh terminal session works great with no setup.

otherwise, i think it works best if you have an editor that supports remote filesystems.

vim and emacs are the classics. both basically let you just specify remote ssh/scp paths when opening a file.

if you want something more modern, i’d recommend Visual Studio Code, which is lightweight, cross-platform, has a good lua plugin with syntax+linting and good support for remote FFS.

i’m sure similar results are possible with other modern editors like Atom.


i tried intellij IDEA’s lua plugins, but this didn’t do the trick for me; remote editing was fiddly to set up and there were a lot of complicated assumptions / config options about project structure and lua "SDK"s.


#352

I don’t have my Norns yet; just found one on reverb and it’s coming soon.

Codepen.io and other online repls support vim keybindings.

Does maiden support vim keybindings in the browser?


#353


#354

Thanks!
That’s slick. I can’t wait.


#355

I’m trying to write a small animation for the screen.
I need visual feedback in a script when saving a table or executing another “trigger” type task (copy, paste, randomize etc).

I experimented with metro but I’m not sure that’s the best solution because inevitably at a moment I get this error message : metro.alloc: already used max number of allocated script metros

What is the best way to proceed? Can I finish the process of a metro once it has reached its maximum counter? stl: stop () stops it but does not deallocate it.

How can I do please ?

This function draws multiple / at a given fps then erases the portion of screen (redraw_portion).

function anim(x, y, z, s)
  local d = 0
  local x = x or 120
  local y = y or 62
  local z = z or 5
  local s = s or 0.08
  an = metro.alloc()
  an.count = z
  an.time = s
  an.callback = function() 
      d = d + 1
      screen.move((x - 10)+(d*3), y)
      screen.level(2 + (d*2))
      screen.text("/")
      screen.update()
      if d == z then  
        redraw_portion(x-10, y-10, 120, 20)
        an:stop()
      end
    end
  an:start()
end

function redraw_portion(x, y, w, h) -- mask a portion of the screen with a rectangle of level 0
  screen.rect(x, y, w, h)
  screen.level(0)      
  screen.fill()
  screen.stroke()
  screen.update()
end

Where can I find the startup animation ? Maybe I could use this code as an inspiration…


#356

you can re-use your metro instead of creating a new one each time.

just move an = metro.alloc() above the function. and it’ll only allocate one time.

(this brings up a good point that we need to update the metro.free() function)


#357

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


#358

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.


#359

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


#360

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


#361

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.


#362

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