Norns: studies



I tried loading a different script, but after renaming the renamed script always gives the repeated error.


I’m trying study 1 tonight and running into this when starting with the section on the key function:

lua: /home/we/norns/lua/paramset.lua:177: attempt to index a nil value (field '?')
stack traceback:
	/home/we/norns/lua/paramset.lua:177: in function 'paramset.t'
	/home/we/norns/lua/menu.lua:690: in field 'key'
	/home/we/norns/lua/menu.lua:144: in function </home/we/norns/lua/menu.lua:121>

Is this due to the syntax change mentioned earlier or am I doing something wrong?


does the script still work? i believe this is a harmless error message from the param system (which i’ll fix in the next release)


No, the script is odd. I also tried loading Study 1 from the Study folder and also pressing key 2 takes me back to the script browser as if I didn’t load it. Other scripts seem to load and work normally.

I did a little more testing, loading other scripts as well from maiden. The odd thing is that when I go back to my test script, the error I get for an encoder shows the path for the last script I ran:

lua: /home/we/norns/lua/paramset.lua:166: attempt to index a nil value (local 'param')
stack traceback:
/home/we/norns/lua/paramset.lua:166: in function ''
/home/we/dust/scripts/mhetrick/easygrain.lua:113: in function 'encoders.callback'
/home/we/norns/lua/encoders.lua:56: in function 'encoders.process'

The script I was running to test was this:

-- many tomorrows
-- norns study 1 = "TestSine"

function init()
  print("the end and the beginning they are the same.")

function key(n,z)
  print("key " .. n .. " == " .. z)

function enc(n,d)
  print("encoder " .. n .. " == " .. d)

Looking at the developer tools, I see a 404 error for http://norns.local/maiden/snippets/text.js which makes me believe there is something wrong with maiden maybe?


My suspicion is that it may actually be normal behavior - unfortunately I don’t have a device handy to check. I believe @ppqq had enabled some support for snippets in the editor, my guess is it’s looking snippet text which may not have been added to the build or was intended to be provided by an enterprising individual.


what’s happening is there was a “feature” added to lockout PLAY screen for scripts not defining redraw() which is of course a bug for study 1.

the “feature” has been removed, so the next update will have study 1 working fine. in the meantime you can define a blank function for redraw and it’ll work as expected.


Thanks, that fixes it!


confirmed. not great though and definitely something to track down…


I’m working my way through study 3 - got to this point - but cannot get a peep out of this code …. lower half is matrons response. Any ideas?

-- from norns study 3
-- quck script that creates a simple ascending strum pattern = "PolyPerc"

function init()
  print("my init")
  strum = metro.alloc(note, 0.05, 8)

function key(n,z)
  print("my key")
  if n == 1 then
    root = 40 + math.random(12) * 2

function note(stage)
  print("my note")
  engine.hz(midi_to_hz(root + stage * 5))

function midi_to_hz(note)
  print("my midi to hz")
  return (440 / 32) * (2 ^ ((note - 9) / 12))
# script load
# cleanup
# script clear
# script run
loading engine: PolyPerc
Engine.register_commands; count: 6
___ engine commands ___
amp	 	f
cutoff	 	f
gain	 	f
hz	 	f
pw	 	f
release	 	f
___ polls ___
# script init
my init


actually - I noticed that when I dragged the above script into the reply box, it looked ok correctly indented etc. but once entered the indentations are lost - what’s the trick here?


enclosure your post in triple backticks (```)



i edited your post, check it out.

will investigate your script shortly


Many thanks T - I know you guys are busy - so when you can, is super fine with me :smiley:

Ah! 1st mistake I see is the double quotes around the engine name.
Changed to single quotes - still no sounds. Matron details the same

Above ‘strum’ code problem SOLVED. I’ve now got this working - but by a slightly fortuitous route. I’ve got into the habit of adding in a print statements, often with in a function, as an aid to debugging. Originally, not only was I not getting any sound - but I only saw ‘init’ function working and nothing else. Eventually, as a trial I added this at the end of the script.

function redraw()

Then my debugging prints appeared along with the strums. Hooray! Removing all the debugging prints made, as expected, no difference - it still worked. Removing this small function once again produced silence.


there’s an unfortunate bug that was originally thought of as a feature in the current build. scripts without a redraw() function get locked into MENU mode, so there’s no way to trigger key/encoder input.

you’re correct that the solution is to define redraw but this bug will be solved in the forthcoming update. thanks for your patience and nice work discovering this


Would be good to add this to the documentation for studies. Issued PR. Unless of course the forthcoming update is imminent!


update is forthcoming. i’d prefer for defining redraw to not be required, and the change has been made to follow.


No worries! Just took a little time to track down the issue here as I was working through the studies.


Was working with study 2 (Patterning) and it seems that the init function doesn’t work.

The init() as it is gives me this in maiden:

lua: /home/we/dust/scripts/jonnybutler/patterning.lua:25: attempt to perform arithmetic on a nil value (global 'number')

stack traceback:

/home/we/dust/scripts/jonnybutler/patterning.lua:25: in function 'encoders.callback'

/home/we/norns/lua/encoders.lua:56: in function 'encoders.process'

But if I put the 2 variables outside a function at the top of the script, all seems well:

color = 3
number = 84