Norns: tutorial

tiny heads up that util.clamp(min,max,input) is always available, no need to define it locally

2 Likes

I was actually confused about this. Do you need to require "util" or not to use util.clamp etc.?

If not - then why are some libs like musicutil not available all the time?

util and tabutil are used a lot and so they are added globally by default: https://github.com/monome/norns/blob/master/lua/core/startup.lua#L4

2 Likes

Since the tools seem to be shifting quite fast, I will try to make the tutorials as stand-alone as possible, I was thinking maybe a further tutorial, would be about including libraries.

I think these different interfaces are a result of two different ways of managing voices in SuperCollider. e.g. PolyPerc doesn’t have any kind of voice management, it just fires off a one-shot amplitude envelope when you use .hz() I had to watch Eli Fieldsteel’s SuperCollider tutorials on YouTube to get a handle on that.

I wonder if under the current model we might need engine-wrapping “middleware” in lua that checks what an engine responds to and fires off the appropriate method — and your script introspecting all these engines is a good first start.

2 Likes

I could make a small tool that handles that if someone else want to implement engine switching :slight_smile:

I’ve added a series of links to the tutorial:

Useful Links

6 Likes

I have replaced the engine tutorial with a tutorial that explains how to include relative files.

Include

In Maiden, look at the tenth example file of this tutorial.

  • Navigate to the tenth example with code > tutorial > A_include.lua.
  • Run the script by clicking on the play button to the top right of the Maiden window.
  • Rotate the knobs to change the position values of the included file.

Including files with local view1 = include('lib/view1'), will first look in the directory of the current script. This allows using relative paths to use libraries local to the script. The returned value of the included script will be available in your main script file.

-- lib/target.lua
return {
  value = 5
}

-- main script
local target = include('lib/target')
print(target.value)
7 Likes

Added a new tutorial that explains how to add and read parameters.

Parameters

In Maiden, look at the eleventh example file of this tutorial.

  • Navigate to the tenth example with code > tutorial > B_parameters.lua.
  • Run the script by clicking on the play button to the top right of the Maiden window.
  • Press the leftmost key, rotate the leftmost knobs to the right, to see and modify the available parameters.

New parameters can be added with params:add, and read with params:get.

-- Add
params:add{type = "number", id = "number", name = "Number", min = 1, max = 48, default = 4}
params:add{type = "option", id = "option", name = "Option", options = {'yes','no'}, default = 1}

-- Read
print(params:get("number"))
7 Likes

Everyday I learn new things about Lua, and today I learnt how to utilize the :method() syntax and rebuilt the Include example to demonstrate how to use it.

Include

In Maiden, look at the tenth example file of this tutorial.

  • Navigate to the tenth example with code > tutorial > A_include.lua.
  • Run the script by clicking on the play button to the top right of the Maiden window.
  • Rotate the knobs to change the position values of the included file.
  • Press the key to select a different view.

Including files with local view = include('lib/view'), will first look in the directory of the current script. This allows using relative paths to use libraries local to the script. The returned value of the included script will be available in your main script file.

-- lib/target.lua
return {
  value = 5
}

-- main script
local target = include('lib/target')
print(target.value)

In lua, you can create new objects and methods as described the following snippet, notice how the self parameter is omitted when using the colon character before the method name.

obj = { c = 4 }

obj.add = function(self,a,b) 
  return a + b + self.c
end

obj:add(2,3) -- 9
8 Likes

In Maiden, look at the softcut example file of this tutorial.

  • Navigate to the example and run the script.
  • Connect a sound source, into the 4th input(Input 1) from the left of the Norns.
  • Fade between the sound source and the recorded loop, by rotating the leftmost knob.
  • Change the offset of the recorded loop, by rotating the second knob.
  • Change the length of recorded loop, by rotating the rightmost knob.
  • Change the playback speed, by pressing the rightmost buttons.

Softcut is a recording tool built into the Norns, it makes it easy to record and play samples at various speed. Generally, the softcut methods will operate on a voice, softcut has a maximum of 6 voices, so the functions are always in the format of .method(voice_id,value). For example, here a few methods used in this example file:

  • softcut.fade_time(1,0.25), set the fade in/out length of the sample, of voice1, to 0.25.
  • softcut.rate(1,2), set the rate(speed), of the sample to play, at speed 200%, also -2 would play in reverse.
  • softcut.loop_start(2,0.5), set the offset of the sample, of voice2, to 0.5.
  • softcut.loop_end(3,4), set the limit of the sample, of voice3, to 4.

You can also explore each one with the Softcut Studies.

13 Likes

The camera shutter was slightly too slow to capture the screen, but this is the softcut patch in operation, using a monotron as source source. I was intimidated with softcut for a while since but it’s actually pretty straightforward, you should give it a shot :slight_smile:

11 Likes

Thanks for these tutorials, very clear and concise!

So I’m trying these out for the first time and reached the fifth example (output) but getting no sound, plus repeating errors in matron:

stack traceback:
/home/we/dust/code/tutorial/5_output.lua:114: in field 'event'
/home/we/norns/lua/core/metro.lua:165: in function 
</home/we/norns/lua/core/metro.lua:162>
lua: /home/we/dust/code/tutorial/5_output.lua:114: attempt to 
call a nil value (field 'hz')
stack traceback:
/home/we/dust/code/tutorial/5_output.lua:114: in field 'event'
/home/we/norns/lua/core/metro.lua:165: in function 
</home/we/norns/lua/core/metro.lua:162>

Also sixth example (input) wont load either.
(I recently updated norns to 190801 if that makes a difference?)

Cheers

Did you SYSTEM>RESET or otherwise reboot norns since installing the tutorials? It needs this to find the OutputTutorial engine used in the scripts.

2 Likes

Ack, you’re right of course. Reset fixed it. THANKYOU! :sweat_smile:

I’m getting an error as I have an old (?) tutorial installed which I’m not able to overwrite. I looked at this for a solution.

From there I got this:

git init .
git remote add -t \* -f origin <repository-url>
git checkout master

…which doesn’t work for me either. I still only have tutorials that go up to part 9. What am I doing wrong? Thank you!

You could just delete the old folder and use git clone https://github.com/neauoire/tutorial.git to re-install.

or, maybe use git pull inside the old tutorial folder to update it.

1 Like

I don’t really know how to remove files so I tried git pull

I got this:

error: Your local changes to the following files would be overwritten by merge:
	1_blank.lua
	3_interaction.lua
	4_animation.lua
	6_input.lua
Please commit your changes or stash them before you merge.
Aborting

options

  1. stash and pull
cd ~/dust/code/tutorial
git stash
git pull
  1. remove and re-clone
cd ~/dust/code
rm -rf tutorial
git clone https://github.com/neauoire/tutorial.git
1 Like

For completeness!

  1. throw away local changes and pull
cd ~/dust/code/tutorial
git reset --hard
git pull
1 Like

i found the answer i needed

1 Like