Tempo Tap tool

Does this tool has a discussion thread already? If so please merge them. There is no link from the Tools site page and I had no luck with the forum Search feature.

http://www.renoise.com/tools/tempo-tap

Mainly I wanted to check that there would be no qualms of me using parts of the code in my own tool (of multiple keyboard/midi shortcuts/functions I feel are missing) and whether any kind of acknowledgement would be desired by Bantai.

Apart from that there were a couple of note:
Now we have graphical automation of BPM in the Master track maybe the BPM commands should be inserted there, rather than creating and using a Send track.
Possibility to record to graphical automation, rather than only patter effect commands.

This bit of code to find the Master track:

 local master_track = nil  
 for k,t in ripairs(renoise.song().tracks) do   
 if (t.type == renoise.Track.TRACK_TYPE_MASTER) then   
 master_track = k  
 end  
 end  

can be simplified to:

local master_track = renoise.song().sequencer_track_count +1  

And what if there are sendtracks?

It could be optimised a little bit though by adding a break when the master is found (it doesn’t need to go through the send tracks)

 local master_track = nil  
 for k,t in ripairs(renoise.song().tracks) do   
 if (t.type == renoise.Track.TRACK_TYPE_MASTER) then   
 master_track = k  
 break  
 end  
 end  
  

Send Tracks start from renoise.song().sequencer_track_count +2

I know this as it’s what I’ve used in my code for deleting automation from Send tracks.

Description of renoise.song().sequencer_track_count from the API.

“-- number of normal playback tracks (non-master or sends) in song.”

While this is currently true, this is obviously something that could change in a future update to the API. The Master track could theoretically be repositioned after the Send tracks and then have the last index, for example. For this reason, and just as a good general coding practise (within our API anyway), it’s always best to check for track.type == renoise.Track.TRACK_TYPE_MASTER (or whatever the case may be) rather than assume it will always be in a fixed position.

The overhead from looping through each track to check its type is also pretty insignificant in the grand scheme of things, so this is definitely not something you need to worry about in terms of optimising your tool’s performance. You should only need to perform this lookup once at the start of your code for most basic usage. In more complex situations where your tool may be running constantly and the number of tracks may change during this time, then you can simply add a notifier to renoise.song().tracks_observable and perform the master track lookup there, too.

If you’re really concerned about saving a few CPU cycles, then perform your lookup in reverse track order, since there will likely be far less Send tracks to work through in reverse before you reach the Master:

  
local function get_master_track()  
  
 local song = renoise.song()  
  
 local type_master = renoise.Track.TRACK_TYPE_MASTER  
  
 for t = #song.tracks, 1, -1 do  
  
 local track = song:track(t)  
  
 if (track.type == type_master) then   
  
 -- Found the master track. Yay!  
 return track  
  
 end  
  
 end  
  
 -- Could not find the master track. WTF?!  
 return nil  
  
end  
  

Hey i found this tool quite helpful in the past and wanted to ask if there is a plan to transfer it to the new Renoise Version 3.0? Thanks a lot!

You can drag and drop the 2.8 version in Renoise 3 and it is automatically converted for R3. I think that only more complex tools wont covert.