Help needed: Sample Recording done notification

I’m trying to detect in my LUA script when sample recording is done and if it was successful (i.e. new instrument with sample created).

Since there is no direct access (yet) to the sample recording dialog I was trying to use a notifier coupled to:

  • renoise.song().selected_instrument, _observable
  • renoise.song().selected_sample, _observable

The problem is that when the sample recorder creates a new instrument to store its successful recording, the selected_instrument changes and triggers my callback function before the sample recorder is fully done.
After some testing I found out that at the moment the selected_instrument callback function is called:

  • no sample data exists yet
  • the instrument is yet to be named by the sample recorder (“Recorded Sample xx”)

Since I’m making changes to some sample properties in my script, this poses a problem.
When executing the same callback function by calling it from a menu manually (many cycles after the sample recorder is fully done), everything works as I hoped for.

The other problem I’m having is to detect an unsuccessful recording. The conditions for that one are:

  1. no successful recording detected
  2. sample recorder is closed

Assuming my first problem is solved with an appropriate notifier, it also provides me with condition 1 for this second problem. For the second condition there is still a problem. Since there is no wait function in LUA (the only OS independent option is busy waiting), I can’t be polling the renoise.app().window.sample_record_dialog_is_visible. So also for this I need to use a notifier. Don’t know which one to use.

I’ve been at this for quite some hours and would really appreciate it if somebody can point me to the best observables to use (if any). :)

Thanks!

1 Like

Hmm,

Problem (as I understand it at the mo): Selected instrument callback is fired but BEFORE the instrument name and sample data appears in Renoise so you can’t get access to those variables (I take it they are nil or whatever) in the callback. Now I’m assuming you’ve looked at every other observable etc… If I was in that situation I’d be thinking timers (or use the idle notifier function) and flags. i.e set a timer function notifier callback up (say called every 100-200ms). Just set a flag in the selected instrument callback that says that a new instrument has been created. In the timer (or idle notifier) callback function you then keep querying if the data has appeared yet:

I.e. (some funny strange code)

  
  
local new_selected_instrument_flag = false  
  
function timercallback() -- <= this will be called every say 100ms (or whatever you set it to) (or use the idle notifier)  
 if (new_selected_instrument_flag == true) then  
 if (data_in_sample ~= nil and name_instrument ~= nil) then  
 new_selected_instrument_flag = false --clear the check flag  
 -- Must have some sample data and name in our new sample here   
 -- Do whatever...  
 end  
 end  
end  
  
functon select_instrument_callback()  
 new_selected_instrument_flag = true --Right set the flag, we know a new instrument is created at this point  
end  
  

That’s very very rough. Now I’m not saying it works (this is off the top of my head) but I’m trying to give you a quick idea on what road I’d be going down to try and monitor when buffers appear in Renoise :)

Hi 4Tey,

a timer callback function seems perfectly suited for both my problems. Still rather new to LUA scripting and hadn’t thought of that at all.
I’ll give it a shot right away. Thanks!!

Works like a charm. Many thanks :)

No problem sir :) Now you can script that elusive piano roll ( http://imgur.com/2ILOktW ) :D

Fantastic idea! Is it just a concept animation or has somebody actually made significant strides in implementing one? It looks totally convincing :)

It is genuine. Linux C build with Lua script. Something I put together this past week. Not very advanced it does next to nothing for the musician as is.

Funny to watch a track plotted in piano roll format however! ;)

I like it a lot. :) I’m sure plenty of people here would be very excited to try it at some point. Are you planning on developing it further into something fully functional?

:eek:

Develop it further? Errrmmmmmmmm…trying to decide on that to be honest. Of course we are not talking just a basic script here. It would be quite a challenge (to say the least) to get it to just something sort of practical. My implementation would be as simple as possible. It would have a lot of limitations. I’ll probably keep messing around with it…well you never know! :D

Oh! Looks like someones jaw just dropped :D

Haha, I appreciate the honesty. If you ever decide to do something with it in the future, I would be happy to help (both in terms of implementation and/or concept design). :)
Anyhow… keep up the good work :)

I would be happy to help (both in terms of implementation and/or concept design).

Sorry for the late reply. Thank you for offering sir smile.gif

It is worth saying that this is a very experimental tool (it will only work on Linux 64-bit OS anyway.) It isn’t ment to be taken seriously or anything. I wanted to get an idea on how fast Lua script in Renoise would send/receive messages to an external program via UDP sockets (that’s how it got started.)