Tool: Write Bpm To Master Track

Every find yourself wanting to make a BPM automation easily? This script does it for you.
It writes the current BPM to the first column in the Master track. Although if you are in a different column in the master track it will write it there.

Set your BPM as usual then right click in the pattern editor and click the new menu option or you can create a key assignment.

2061 WriteBPM_2.7.0.xrnx
2746 WriteBPM_2.8.xrnx

:drummer: good idea :)

I was wondering…

  
function write_bpm()  
 if renoise.song().transport.bpm < 256 then -- safety check  
 local column_index = renoise.song().selected_effect_column_index  
 if renoise.song().selected_effect_column_index <= 1 then column_index = 1 end  
 renoise.song().selected_pattern.tracks[get_master_track_index()].lines[1].effect_columns[column_index].number_string = "F0"  
 renoise.song().selected_pattern.tracks[get_master_track_index()].lines[1].effect_columns[column_index].amount_value = renoise.song().transport.bpm  
 end  
end  
  

What if the BPM would raise 255, we solve it like this?:

  
function write_bpm()  
 if renoise.song().transport.bpm < 256 then -- safety check  
 local column_index = renoise.song().selected_effect_column_index  
 if renoise.song().selected_effect_column_index <= 1 then column_index = 1 end  
 renoise.song().selected_pattern.tracks[get_master_track_index()].lines[1].effect_columns[column_index].number_string = "F0"  
 renoise.song().selected_pattern.tracks[get_master_track_index()].lines[1].effect_columns[column_index].amount_value = renoise.song().transport.bpm  
 else  
 renoise.song().transport.lpb = (renoise.song().transport.lpb*2)  
 renoise.song().transport.bpm = (renoise.song().transport.bpm / 2)  
 write_bpm()  
 end  
end  
  

That’s a good idea vV. I was thinking about doing something to do with the LPB.

I think the LPB has to be written into the master track as well using the LPB effect command.
One might want to switch LPB values in specifica patterns if you really want to expand on tempo automation.

cool lill script! Thanks!

Hiya, I really think Write BPM should be WriteBPM&LPB. Would really help.
I’ve tried to make the modification myself, but so far have not found a way of enlarging the Master track “effect column”.
I have a feeling I already know it, but am too tired to put it in.

  
  
function write_bpm()  
 if renoise.song().transport.bpm < 256 then -- safety check  
 local column_index = renoise.song().selected_effect_column_index  
 if renoise.song().selected_effect_column_index <= 1 then column_index = 3 end  
 column_index = 3  
 renoise.song().selected_pattern.tracks[get_master_track_index()].lines[1].effect_columns[1].number_string = "F0"  
 renoise.song().selected_pattern.tracks[get_master_track_index()].lines[1].effect_columns[1].amount_value = renoise.song().transport.bpm  
 renoise.song().selected_pattern.tracks[get_master_track_index()].lines[1].effect_columns[2].number_string = "F1"  
 renoise.song().selected_pattern.tracks[get_master_track_index()].lines[1].effect_columns[2].amount_value = renoise.song().transport.lpb  
  
 end  
end  
  

Anyway, column_index does nothing, obviously :)
Seems like the thing is that a selected_track can have a visible_effect_columns=2 set, but getting the script to do that to the master is slightly annoying :)

P.s. ended up modifying my song template to have 2 columns on Master automatically :)

There is a fairly easy way to detect what type a track is.
There can only be one master, once you know which that one is, expanding the effect columns is peanuts.

-------- Constants

renoise.Track.TRACK_TYPE_SEQUENCER
renoise.Track.TRACK_TYPE_MASTER
renoise.Track.TRACK_TYPE_SEND

maybe for a future update this tool can be pimped so you can set a beginning and end bpm within a range (pattern / sequence / song?) and the tool interpolates between the set values.

I.o.w sort a like automating bpm rate through pattern commands. Something that would disable the need to make a selection in the pattern editor and interpolate through the advanced editor.

Detect, yes, but if the effect_column depends on selected_track, then either I learn how to set effect_column amount to 2 on a “TRACK_TYPE_MASTER”, or learn how to set selected_track to “TRACK_TYPE_MASTER”.
Which method would you recommend? :)

if you looked in my code you’d see i have a function to tell you which track is master.

function get_master_track_index()  
 for k,v in ripairs(renoise.song().tracks)  
 do if v.type == renoise.Track.TRACK_TYPE_MASTER then return k end   
 end  
end  

so you could then do this line of code somewhere to change it or find out what it is. remember there are always 8 columns but they are just hidden.

show
print(renoise.song().tracks[get_master_track_index()].visible_effect_columns)

change
renoise.song().tracks[get_master_track_index()].visible_effect_columns = 2
renoise.song().tracks[get_master_track_index()].visible_effect_columns = 4

you can’t set a track type as far as i know. if you think about it it makes sense why there would be issues with that.

I would recommend you to use the Syflom’s iterator here. If the specific function needs to be applied to the master track, then simply write the stuff to the effect column in the master track. No need to have this track “selected” specifically.
You do need to get the selected_line index and the selected pattern index and the master track index is provided to you by Syflom’s routine, from there you can change the effect-column data to your needs.

Have updated the tool for 2.8 due to the changed ZTxx command.

You might give it a thought for adding support for the Automation parameter for the master track. The master track is the only track that now also supports BPM, LPB and TPL changes through automation.(Automated fractional bpm :D)