Executing A Script / Function With Timing ?

Ok that is awesome! But I can’t figure out how it produces notes. It works actually like the signal follower just with 3 variable inputs and self made mathematical expression (which is nice) but seems to act only for the DSP effects of the track, or am I missing something? It is still dependent on the pattern editor content. But still this is a VERY NICE approach to live coding! Just want to use it also in the note domain, and not only for controlling parameters.

Thanks for all your answers, I’ll keep messing around with the observables :)

You’re right, Formula Device is only control data, not note data. So similar to an LFO or Signal Follower but you can give it its own rules based on a lot more parameters, such as song position and combination of inputs.

Tools so far have no real-time component. You could write scripts which generate your notes and enter them (there re already some for chord progressions and the likes) but not to do things live on the fly. Well not 100% perfectly anyway. You’ve not said what you want your Function to do every pattern start of 8th note or whatever… These are things the Formula Device does give you access to but only with control/meta data as output. For programming notes not sure how you’d approach it…

Well, I’m quite happy with the performance at the moment of live scripting. I know it wasn’t intended for this, but if we have an interpreter, why not…? ;)
I would like just to define a function which puts some notes on the grid with certain probabilities, or patterns, so when the player plays the last line (e.g. 64) it regenerates the notes on that column with the same rules/probabilty, therefore conserving some properties but with some changes from repetition to repetition. Another thing I would like to do is to define scales and progressions (as you already mentioned, there are some) and also with some probability (even markov chain analyzed data) generate melodies and rhythms. I have already a small library for ‘trying’ to make chiptune, which defines some scales and rules for the rhythm and the melody and gives me out a midi file. I would like to do this live with renoise, I hate making midi files and importing them again and again…

So yeah, that’s basically my approach. While one or two tracks change themselves on every repetition, I can improvise with the keyboard or write notes on other tracks manually and stuff like that.

I can imagine a device like the formula device that also takes for example: current_note_value, and you can change it or leave it as it is before executing. Maybe should I post this suggestion on the suggestions forum? don’t know if people work like this anyway, but I find it nice to generate content from a script and then change it manually or keep it generating on every repetition or every n ammount of beats/lines/whatever. :)

I also can imagine sending an osc message to another computer on every beat or so, for example for visuals (w/o using midi clock). There is LuaAV which I also like a lot and someone brought me to the idea to writ a script for renoise + LuaAV. Will try this this evening. In that case would be nice an OSC clock, or as I asked, a function on every line change/beat so the video host has also some timing information :)

So, sorry the triple post…

@KMaki: I was trying the observable/notifiers and there are pretty much observables for everything except that what I’m looking for. What you suggested works (fires a function) but when I manually edit something in the pattern.
I think what I looking for is in the transport:

renoise.song().transport.playback_pos  

But it doesn’t has an observable. With this:

renoise.song().transport.playback_pos.line  

I get exactly where the playhead is at the moment, it would be pretty easy to make an observable that check this:

if line == 1 then ... end   

How can I make a feature request for this? I mean, there are observables for everything else, so… why not one for the transport position? ;)

This Tool reverses playback direction. I believe to do so it looks at when playback line increases and then deducts 2 from it, to move back a line rather than forwards. Maybe you can find what you need from within its code. (Not actually delved into it myself, only going on description.)

Oh, that’s a nice example! It uses:

renoise.tool().app_idle_observable  

which isn’t synched to the beat but calls itself in the background depending on the load. From the documentation.

So, yes, this would be a workaround, will try this when I get home. I still think a playback_pos_observable would be good (not only for me) but as I said, for example to send beat synced osc or midi to a device or computer.

I think this has been at least discussed (if not directly requested) before. Try a forum search on ‘playback observable’ or something like that. I recall the reason it is not there is that in practice it puts too much strain on yer CPU… Oh, yeah, and that the observable it would always ‘lag’ a certain amount anyway. Would be awesome to have it, though!

And BTW impressing stuff, you post! :)

EDIT

Hey yes, I think it should come with a warning, like the app_idle_observable. It warns it’s inaccurate and one shouldn’t use heavy functions to spare cpu. So I would practically wouldn’t evaluate on the beat bot one or two lines before. At least less hacky than having a function in the background checking if the play position has changed and then executing a function. I will try the thing later on with the visuals host (also Lua) then people could use this for that kind of thing and not only for my purpose (live coding).

And thanks, I’m glad you liked it, It’s quite basic now, still want to make a library so I need less code and really improvise with this.

*** EDIT: oh yes, I was looking on the forums but only found your post. maybe I should put this on the suggestions forum/thread? I don’t know what is the standard procedure in the community… ;)

Look at the Baguetter.

http://www.mynameiskaneel.com/blog/2011/09/23/the-baguetter-a-renoise-2-7-tool/

It triggers an action every X lines. It uses app_idle_observable.

It’s not perfect timing, but it’s not bad either.

Hey, thanks! I like his approach more, it’s a little bit cleaner. Will be using this approach for the moment.
Quote from his source code comments:

So, I understand we don’t want to load too much the cpu, but as people are complaining about this, would be nice to have a solution for this timing problems.
I know a lot of renoisers don’t use the scripts at all or their tools are OK to work NRT, so I understand if this is not a priority. But it would be actually really cool to have this.
I will post my approach tonight when I have it working, and also to show how nice it could be to send osc on beats for an audiovisual performance :)

Well, it’s been discussed before in other threads, but the first step to solving this problem is for LuaJit 2.0 to come out of beta. The LuaJit repo still gets a lot of action and the devs aren’t willing to implement LuaJit until a final release is stamped with a seal of approval. This “precise” timing issue is exactly why Renoise is written in C++, and not Lua. ;) LuaJit will improve things, and open the door for faster processing, maybe even DSP stuff.

Some clever hack suggestions:

Use: renoise.song().transport.edit_mode_observable (or any other toggle button, like chord mode) to trigger actions, DJ style.

Use: renoise.song().sequencer:sequence_is_start_of_section_observable(sequence_index). Here, you could create sections headers (new feature in Renoise 2.8) and when a certain header is reached durring playback, a script is executed.

And so on. Good luck!

Oh, yes, I’ve been waiting for LuaJit 2.0 too for other projects. Still not compatible with the fresh Lua 5.2, but I guess I can wait for this :)

Very nice! thanks for your suggestions! the sequence_is_start_of_section_observable seems good for my purpose and doesn’t have to be evaluated every line. :) Thanks!

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 ;)