Norns: scripting

norns

#323

This looks/sounds awesome!


#324

Wowwww this is amazing


#325

I hope I get a chance to play with this someday. So flexible and powerful.


#326

hitting a Lua n00b wall with comparing tables.

attempting some 1-d CA stuff (a la ‘less concepts’), basically translating seed integers to binary and using comparisons against a fixed set of neighborhood rules to determine note events. stole a compare function from the internet.

so far, I have...
seed = 30
rule = 251

function seed_to_binary()
  seed_as_binary = {}
  for i = 0,7 do
    table.insert(seed_as_binary, (seed & (2 ^ i)) >> i)
  end
end

function rule_to_binary()
  rule_as_binary = {}
  for i = 0,7 do
    table.insert(rule_as_binary, (rule & (2 ^ i)) >> i)
  end
end

function init()
  seed_to_binary()
  rule_to_binary()
  seed_packs ={}
  seed_packs = {  {seed_as_binary[1], seed_as_binary[8], seed_as_binary[7]},
                  {seed_as_binary[8], seed_as_binary[7], seed_as_binary[6]},
                  {seed_as_binary[7], seed_as_binary[6], seed_as_binary[5]},
                  {seed_as_binary[6], seed_as_binary[5], seed_as_binary[4]},
                  {seed_as_binary[5], seed_as_binary[4], seed_as_binary[3]},
                  {seed_as_binary[4], seed_as_binary[3], seed_as_binary[2]},
                  {seed_as_binary[3], seed_as_binary[2], seed_as_binary[1]},
                  {seed_as_binary[2], seed_as_binary[1], seed_as_binary[8]}  }
                
neighborhoods = { {1,1,1},
                  {1,1,0},
                  {1,0,1},
                  {1,0,0},
                  {0,1,1},
                  {0,1,0},
                  {0,0,1},
                  {0,0,0} }

if compare (seed_packs,neighborhoods) then
    print("true!")
  else
   print("false")
end
end

function compare (s, n)
  if type(s) == type(n) then
        if type(s) == "table" then
                  for loop=1, 3 do
                    if compare (s[1][loop], n[8][loop]) == false then
                        return false
                    end
                  end

                return true
        else
            return s == n
        end
    end
    return false
end

getting stuck with the compare function working with the tables. right now, it’s only able to return results comparing line 1 of the seed table and line 8 of the neighborhood table. it currently verifies that binary seed cluster #1 (000) matches neighborhood #8 (000).

however, I want it to return ‘true’ when a line of the seed table matches a line of the neighborhood table, basically like this:

does binary seed cluster #1 match neighborhood #1?
if yes, event and move on.
if no, move on and try with seed cluster #1 + neighborhood #2, then neighborhood #3, etc etc until neighborhood #8, then:
does binary seed cluster #2 match neighborhood #1?
and again.

this is likely murky, but figured I’d ask :slight_smile:


#327

Check this out maybe


#328

ah! duh. totally spaced on elca!

are there any example scripts that utilize it or show a simple application? i couldn’t wrap my head around elcos before it got pulled.


#329

I can resurrect elcos and make it run in the new script framework. it’s pretty simple

My favorite trick with running elca in the grid, is allowing you to toggle a cell in the history, and altering the current rule such that the new state would have been produced


#330

that’d be dope, thanks ezra!


#331

realizing i won’t have a grid for a while, so for now here’s i think the mos recent version of elcos from the git history

elcos.lua (4.5 KB)

basically the grid turns into a 1D CA sequencer controlling 8x sines. you can scrub the offset in the CA history, you can set incoming pitch to a given sine pitch, change rule / state from grid, change speed with knob. basic


#332

I’m not a coder, but maybe the Zellen Game Of Life CA type script will help? if you’ve not already seen.


#333

when trying to debug why my transpose button wasn’t working expected i accidentally made my version of loom compose itself. a fun moment between annoyances.

question: i want to add a meta parameter that will determine how quickly supercollider responds to changes to the other parameters’ values. generally, does this make more sense to do on the lua side or the sc side?

specifically, i’m still working with @markeats (thank you again) mollythepolly. so i could set up a command to adjust controlLag. but that still leaves lua pumping out the same amount of osc messages reguardless of how many supercollider actually needs, which seems wasteful?

so then i thought about making some kind of function that governs the refresh rate of the parameter state the same way the screen and grid refresh rate are controlled in loom. but then i thought that it seems like something that might already be elsewhere and i am not finding it. but then i thoug–


#334

in norns alphacactus mp_ack where is the grid led brightness code as there does not seem to be any in the script nor the meadowphysics library.

thanks


#335

Not sure if this is the right norns thread for developer tools questions, but, is anyone using codea for norns scripting?

It’s got some good press recently, is a native lua editor, and has inbuilt OSC support.

I’ve just bought it and will see what it can do.


#336

i have fully moved over to the ipad for my scripting but am doing it with blink shell over ssh. open source so if you’ve got a mac you can compile it in xcode and put it onto your ipad for free. (pain to do though because if you don’t have a real dev liscence you have to disable a bunch of permissions related to icloud and notifications and rebuild it once a week, i bought it after 3 weeks). haven’t bothered trying to get mosh running on norns yet, not being able to go to other apps without worrying about crashing vim has been great for my productivity!

OSC makes codea look super interesting though, i’ve got touchosc and could really really use it for my main norns project, but the editor on macos is such an enormous pain to use that i can’t actually make myself do it.


#337

Yeah, both blink and touchosc are on my radar. I’ve used touchosc (and osculator) a fair bit before and share the pain.

C’mon Apple : Xcode for iPad already!

Note to self : also try Coda for iOS.


#338

Anyone tried out Fennel on norns? I’ve been too busy to play around with it, but have had it bookmarked for bit. Hoping to have a bit of time next month to dig into it…


#339

Just in case somebody needs this, here’s a small function for sending NRPN messages (p is the parameter number and v is the value.)

 m = midi.connect()
 device_ch = 1

 function nrpn(p,v)
      local ch = device_ch + 175
      local n1 = p / 128
      local n2 = p % 128
      local v1 = v / 128
      local v2 = v % 128
      return ch, 99, math.floor(n1), ch, 98, math.floor(n2), ch, 6, math.floor(v1), ch, 38, math.floor(v2)
  end

m.send{nrpn(3, math.random(0, 19))}

#340

The Moog Sub37 generally works as a midi device (Sub37 usb out > Norns), but I’m getting an error when I turn the Sub37 arpeggiator on; the error repeatedly posts until I turn the arpeggiator off. Norns receives note event data when the arpeggiator is engaged, so the error does not prevent operation.

I took a look a the current midi.lua file on github but I’m not detecting anything. I’ve included the error and the script code below. Norns is update 181101. Any suggestions?

Error:

lua: /home/we/norns/lua/midi.lua:188: attempt to perform bitwise operation on a nil value (field ‘?’)
stack traceback:
/home/we/norns/lua/midi.lua:188: in function ‘midi.to_msg’
/home/we/dust/scripts/MyTestCode.lua:126: in field ‘event’
/home/we/norns/lua/midi.lua:120: in local ‘event’
/home/we/norns/lua/midi.lua:301: in function </home/we/norns/lua/midi.lua:289>

MyTestCode:

125 midi_keys.event = function(data)
126 local d = midi.to_msg(data)


#341

it seems the sub37 must be sending out some unexpected midi messages, but i’m not sure why it would break the midi input.

@artfwo perhaps we need a midi-debug function/option to just see the raw midi from a device?


#342

looks like the high-level API breaks on clock events (or similar) from the arpeggiator. i am going to push a slightly revised version for pre-2.0 soon, but otherwise just adding a print statement to norns.midi.event will certainly provide more information.