Norns: scripting

norns

#384

I don’t think there’s currently a way to do so, see https://github.com/monome/norns/issues/732


#385

Ok. Shame but understandable. I’ll keep drawing interfaces in Sketch until it arrives :slight_smile:


#386

i mock up ui design for oleds with Processing with noSmooth() enabled

i think a lot of the drawing methods are similar to the Cairo stuff used on norns.


#387

Oh cool. Would you mind sharing an example?

Ignore me, it’s so simple! I’ll share my creations. I’m a UI designer by trade. Keen to start contributing.


#388

#389

Great idea! 20characters


#390

Trying to create a parameter option for grid rotation that includes textual representation of the degrees. As the grid_rotation values are 0 to 3, I’m having a bit of trouble getting things set up. Here’s what I have:

local grid_display_options = {"0", "90", "180", "270"}

    params:add{type = "option", id = "grid_rotation", name = "Grid Rotation", options = grid_display_options, default = 0,
        action = function(value)
        grid_device:all(0)
        grid_device:rotation(value)
        grid_device:refresh()
    end}

The result of this is that grid rotation gets set to the 90 degree value (1 in the array).

Any ideas for how I can fix this? Thanks.


#391

You may want a key/value pair table where you look up the selection so you could do something like
grid_value = {
“0” = 0,
“90” = 1,
“180” = 2,
“280” = 3 }

Then maybe use params.add_option and params:set_action


#392

looks like a zero vs 1-based array problem. maybe a bug - probably my fault

Maybe this would fix:
grid_device:rotation(value-1)

or use Jonny’s solution above. :slight_smile:


#393

Thanks, @jonny and @okyeron. Those were things I had tried. I tend to think it’s the zero vs 1-based array conflict. No worries. Will stick to original plan.


#394

How can I make sure that when saving parameters to the “default” preset slot of a script that those parameters load up next time that I launch the script? Each time I load up my script the default values hardcoded into the script are loaded.


#395

on 2.0, I think you’re looking for

params:read("scriptname.pset")
params:bang()

#396

20 characters of Thank you!


#397

Just wanted to throw out a kudo to @markeats and the several libraries he’s made available for norns. The MusicUtil library makes selecting and assigning note values to scales a relative breeze.

The one I’ve been working with lately is the UI lib. As norns is a screen and knob limited device, scripts which offer multiple options for user control/modification have a challenge.

Among others, the UI lib offers a handy way to create and move through multiple “pages” of Norns-based controls. Mark’s loom script shows how this works. Norns v2 uses a horizontal version, rather than the standard vertical, in the menu system.

I want to offer encouragement to script writers to take a look at this method if you haven’t yet. It’s relatively simple to implement. Everything needed gets located in the KEY, ENC, and REDRAW functions. I’ve added this to my ‘Strum’ script, as it now has on screen 5 performance controls that users should have ready access to. It took me about and hour and a half to implement. EDIT: Those with actual coding skills will be much quicker. :grin:

The UI Pages can also benefit users by having a recognizable way to move through the various controls provided in a script.

I’m not encouraging all scripts look and work the same way. Still, if we think about users, it can be beneficial to have some common method of interacting with norns scripts.

Peace.


#398

Any ideas why params always show up as a float when rendered on norns itself? For example, when I spec:

LUA:
params:add_control("compress", "compress", controlspec.new(0, 100, 'lin', 1, 10, "%"))

SC:
this.addCommand("compress", "i", { arg msg; synth.set(\compress, msg[1]); });

it shows up in norns as
compress 10.0 %


#399

numbers in lua are always double-precision float, unless specific contortions are performed to make them integers.

currently on norns lua side, we don’t really use integers at all (AFAIK). certainly the parameter “control” class doesn’t.

(the only case i can think of where this would really, really matter is if the param value was acting as a bitfield. which would entail its own parameter class i’d think.)

at the C level (between lua and OSC) the value in your example will be cast to int before its sent, b/c of the command format specification.

i suppose it would make sense to tweak the parameter display routine (in lua) to drop the decimal when step size is an integer.


#400

There is also a ‘number’ param type that works well for integers :blush:


#401

Are Lua drawing libraries compatible with Norns? Or, can we import SVG? Thinking of creating more complex interfaces.


#402

norns uses cairo

see https://github.com/monome/norns/blob/master/lua/screen.lua


#403

I did some preliminary research on svg here - Norns: Development

I’ve been experimenting with reading images to pixel arrays to make “sprites”

There’s also a display-png function added in 2.0