Executing A Script / Function With Timing ?

You can attach observables to devices in Lua scripts and then let the lua scripts fire note events a soon as a notifier calls the observable function.
Though it still remains controlling a big cruise-ship in a narrow canal and you can’t make swift turns with a minimum 10msecs of delaytime. (That’s the difference between the formula device and Lua scripting environment and also may perhaps be the reason why some folks are getting Renoise to crash with it, simply because the notifiers get overflowed with data)

So, I tried out some stuff. Here some things/questions

  • The app_idle thing works only in tools, not in scripts, so it’s not usable for this live scripting purpose :( but thought about a tool with a simple text view, much like the formula device, and use internally the app_idle and get the string from the text view with valid lua code. This might work, will have to try this out.
  • Working with a trigger key/function was quite good. Define the functions for every track and generate the content with ESC. Demo video here. Not very good for ‘live coding’ though, but one can modify the algorithm while playing, and then execute it again. And sorry, the snare sounds and pattern are horrible, my bad, it was just a test…
  • I wrote a little script to generate notes in a track, and use the same script in LuaAV. LuaAV tracks for changed files when saved, so it’s quite cool one hit the save+execute button at the editor and it executes in renoise and LuaAV too (if the file changed). Little demo here. Still not in synch at all, which leads me to:
  • I couldn’t get sending OSC messages. The API documentation in OSC and Socket is all bout making a server and receiving messages. Looked for some other tools sending OSC but haven’t found something fruitful. Anyone can point me to an OSC sending tool working? And last, sending OSC led me to the idea of:
  • Making a kind of NetClock (would be much better if it isn’t scripted), but as an internal feature, much like a MidiClock or similar. For example AudioMulch has such a NetClock and it’s very handy when working on different computers or even the same one w/o dealing with the MIDI stuff and having more freedom on the data sent via OSC (i.e. bpm, position, pattern, etc). Is there already something out there like this? or would it be a nice suggestion for the devs?

So, thanks again for all your help, I have now more ideas what to do with Renoise :drummer: to hook it up to other systems and a little live scripting library.

Here the videos embedded:

Dimitri knows about Renoise 2.8 release.

Keep up the good work.

Well, I started making a tool, to be able to have the app_idle working on the background, but first I wanted to ask something. I’m making a kind of mini interpreter to simplify things (bind code to a track for example). Then I have a couple of questions:

How can I make a module or table global? I would like to predefine some functions in the tool, and be able to access them in the mini interpreter. Hasn’t worked yet somehow… I guess the string gets interpreted in it’s own space w/o getting the current state and variables of the tool.

To interpret the code in the text field I’m now using:

local func = loadstring(text_field.text) -- using plain lua code in the text field  
local func = loadstring(text_field.text)() -- using return function () end in the text field   

Executing the code is not a problem, but passing something to that function is. Haven’t got that working yet. My idea is to pass a table with the lines of the current pattern track, so one can iterate over them as one please. So, the code would be basically always just a function with the lines table as argument and a for loop to set the values in every NoteColumn.

This is how it’s looking now (with some default/dummy code).

If I get that working, then it would be easier to bind that to a track and have app_idle do it’s magic. ;)
Thanks for any suggestions and/or answers to my questions.

hey rukano,

very interesting stuff you’re into here !!

i read at your homepage that you’re writing a doctor thesis about improvisation and communication in electronic music ensembles

i.e. we can assume you’re quite educated in this area, so i’m definitely going to monitor your renoise scripting projects… :)

I think creating an embedded code-editor is going to get quite tricky. Syntax highlighting and such is still only available in the lua console.
But I immediately thought about the debug hooks, because it sounds like you are creating these steps to be able to quickly enter some code and hit “execute”.

See debug_hook in the ExampleTool for examples - I think this is the closest you can get to live coding without too much hassle

Each tool get’s it’s own instance of the lua interpreter, so unless the interpreter and the functions are separate tools, you should be able to access the variables.

Put differently: if you define a global variable, only the tool that defined it will be able to read it. But perhaps you defined the variables inside a function? This would make them belong to that function only (assuming you’re not using OO programming techniques here).

Instead of keeping a lua syntax for the generative parts, how about defining your own (token-based, or whatever) language for this purpose?
Apart from keeping the syntax as simple as possible, I have a feeling that this would be easier to maintain in the long run.

Maybe move this thread outside the beginners forum ;)

Hey danoise, thanks for your suggestions! Will look at the debug hook, looks like a ‘cleaner’ hack and for using external editors, might improve the developing speed :)
I like a lot the idea of a mini language to be parsed by the tool and executed in lua code. so basically I would define a kind of pattern syntax, I will have to think this more through though. Feel already like in inception going one level deeper every time. But that’s what I’m looking for, and with an easy syntax, might be usable too for no programmers. kind of:

seq 60 60 r{60,67,72}   

Like for generating 2 notes fixed and the other one random with 3 possibilities. I can think of

seq 60 - - every(4, 67)  

Or something like that. Could be kind of nice, but will be a lot more of work. Maybe next month after some concert might be able to pull this through, but can’t promise anything… ;)

Yeah, exactly that kind of thing.
String handling in lua is not excellent, but it supports regular expressions with callback statements - meaning, multiple levels of recursion is possible.
And yes, it would require a lot of planning

So, after some thinking and almost no planing I decided to give it a try and make a full tool out of this. I started and tested some ideas and now works! Will make a proper thread on it when I’m more advanced and put the code on github if someone want’s to help with this :)

Here a little jam session live coding renoise with my (now code named) ReSeq Tool. If the beginning is boring, skip some minutes. I had a lot of fun, Can’t wait to make this smooth and usable and try it out on a club and put some people to dance with live renoising and scripting :)

Thanks all for your comments, ideas, answers and support!

THE FORMULA FOR C-4 TECHNO HAS BEEN SPOTTED AND IT’S

note: seq -> 48 | 121 | 121 |

Also, wicked bassline at 7:30ish, formula was note: seq -> sin(i) * 4 * 40

Great work, man.

Thanks! :) Well, I’ll make lots of changes in the future, I saw the delimiter | is quite annoying to type every time. Maybe use new line instead, so it looks more like tracker lines, and easier to parse. Also will do some tabs for note, inst, vol, etc… so one can have different codes at the same time, and also a button row with the tracks, so one can appply that to any track (from the tool window). Right now is just using the selected track. Also another idea was to have another code window, to define lua functions, much like the formula device. So less code in the pattern, and maximum flexibility :)

Let’s see where this all leads to.

Nice! Like it when track 3 is added, instant breakbeat :wink: .

Reseq > ac toolbox

:drummer: