interesting pedal. you can take a look at tunnels to get an idea. some of the modes are not far off and just a matter of tweaking a few params. feel free to just add a mode or two and send a pull request! (I actually have a few more that I just haven’t added to the repo yet - and I need to check out the new filtering)

I think it’s a good initial project. if you’re like me, most of your time will be spent discovering how the various params work together.

2 Likes

A question for the residents of Nornsville, regarding the UI module.
I’d like to get some simple playback icons, for example using:

UI.PlaybackIcon.new(64, 5, 10, 1)
UI.PlaybackIcon:redraw()

I’ve tried putting these directly into function redraw() at the end of my script and also wrapping them into a function first, but I keep getting the error:

attempt to index a nil value (global ‘UI’)

I’m sure I’m probably getting some syntax wrong here, so has anyone got an easy example of using the UI module I could see? I’d be keen to use some of the dials and sliders from there too!

Are you importing the library?

ah no, should I be?!
edit: I cant immediately find where the module would be imported from in the docs… hmm

Yes you’ll need to bring it into the scope - that’s why UI is presently nil in your script.
UI = require 'ui' is what you’re after

2 Likes

riiight ok, yes that makes sense! thank you :slightly_smiling_face:

Or maybe keep it local?
local UI = require 'ui'
:slight_smile:

1 Like

definitely a good idea

2 Likes

Thanks again for the tips, but still a bit puzzled by this…

So I’ve got:

local UI = require 'ui'

then:

local function pbicon()
  UI.PlaybackIcon.new(64, 5, 10, 1)
  UI.PlaybackIcon:redraw()
end  

but when I call:

pbicon()

I get:

stack traceback:
[C]: in function ‘s_rect’
/home/we/norns/lua/core/screen.lua:119: in function ‘core/screen.rect’
/home/we/norns/lua/lib/ui.lua:529: in method ‘redraw’
/home/we/dust/code/loopzilla/loopzilla.lua:41: in upvalue ‘pbicon’
/home/we/dust/code/loopzilla/loopzilla.lua:175: in function ‘redraw’
/home/we/dust/code/loopzilla/loopzilla.lua:81: in field ‘event’
/home/we/norns/lua/core/metro.lua:165: in function </home/we/norns/lua/core/metro.lua:162>

I’ve never actually used the UI module so am uncertain here - have you found other scripts using it? Worth seeing how they implement it

1 Like

OK, hah, I’ve fixed it. Basically this syntax works.
Thanks again and sorry for the noise! I should probably go to bed now…

local function pbicon()
  hello = UI.PlaybackIcon.new(64, 5, 10, 1)
  hello:redraw()
end
2 Likes

Has anyone worked with unit tests for lua scripts? I’ve been looking a little into it this morning to allow me to work on things without the unit in front of me.

1 Like

I ended up separating out my Norns script into a testable library script and then a front end script that uses it. That way I was able to do a lot of the work on my Mac and run my tests and then just write the Norns integration on the Norns. There’s probably a better way to do this, but you can look here for what I came up with: https://github.com/JakeCarter/circles/tree/master/lib

5 Likes

Thanks! This is the kind of approach I was thinking.

1 Like

Hello, I have a question regarding polls.

I have the following in my function init:

local pl = poll.set(“amp_in_l”)
pl.time = 0.25
pl:start()

All good so far. Next if I try and reference the poll in the script, such as:

local ampin = pl:update()

I get the following error:

/home/we/dust/code/jiffy/untitled.lua:148: attempt to index a nil value (global ‘pl’)

stack traceback:

/home/we/norns/lua/core/norns.lua:190: in metamethod ‘__index’

/home/we/dust/code/jiffy/untitled.lua:148: in main chunk

[C]: in function ‘dofile’

/home/we/norns/lua/core/script.lua:143: in function </home/we/norns/lua/core/script.lua:143>

[C]: in function ‘xpcall’

/home/we/norns/lua/core/norns.lua:191: in field ‘try’

/home/we/norns/lua/core/script.lua:143: in function ‘core/script.load’

(…tail calls…)

script clear

Tried doing this with/without declaring as local etc, but get the same errors… Any ideas?

I basically want to perform an action when the amp_in_l reaches a certain amplitude.

Thanks!

I guess this should be declared outside of init function.

1 Like

to expand: your init is not run immediately when the script is run, but when the engine is loaded.

also be aware that the local keyword restricts the variable’s visibility to the current function or execution “block.” if you declare a local var at the top of the script (outside a function,) then its “block” scope is the entire script.

you want something like

local pl = poll.set('amp_in_l')

function init() 
--- ... put stuff here that needs to talk to the engine 
    local foobar  --- this variable will not be visible outside of the `init` function
end

(in general, it would be helpful to paste or link the full content of your script.)

3 Likes

Thanks both :slight_smile: the clarification of local scope makes sense - I had also tried including it in init() without local with the same errors.
But, declaring it at the top (outside of init) of the script is what I’m after!
Still making (very tiny, shuffling) baby steps here…

edit: will post links to the code in future

1 Like

haven’t had much time to sit with user scripts lately and need something for an upcoming show. figured I’d ask if this exists before making something simple: is there a script that can allow a user to map samples to a midi controller (keystep, in this case) and then play the entire sample with just a key press (not hold)? don’t need any engine fx, etc

Timber has elements of that. You can loop a sample and map them.