I’ve been working on a session recorder tool, which almost works (code below, not super tidy). It arms a track by a hotkey, automatically records when starting to play pattern and automatically inserts the note (with autoseek) on position where the recording started.
I’m learning to script by reading the documentation and googling a lot, but I take the liberty of asking some questions here. I hope that’s ok.
- When using renoise.song().transport:start_stop_sample_recording() to stop recording, AND recording to the same instrument, the sample doesn’t update. Am I making some obvious mistake?
- Is there a better way to do the notifier function? Maybe it introduces some latency when recording now?
- Is there a way to make global variables that will be accessible the next time I trigger the script? (no0b question)
- Proper handling of track colors and inserting on the right column will be fixed, don’t worry
local trackcolor = false
local armed_track = false
local record_pos = false
local is_armed = false
function initialize()
renoise.song().transport.playing = false -- stops playback in case it was playing
armed_track = renoise.song().selected_track_index
trackcolor = renoise.song().tracks[renoise.song().selected_track_index].color -- save track color so it can be reset after recording
arm_and_record()
end
function arm_and_record()
renoise.song().tracks[renoise.song().selected_track_index].color = { 255, 0, 0 } -- sets track color to red to indicate it is armed
renoise.song().transport.playing_observable:add_notifier(notifier) -- triggers notifier() when playback is started or stopped
end
function notifier()
if renoise.song().transport.playing then
renoise.app().window.sample_record_dialog_is_visible = true -- open record dialogue. unwanted(?) but needed.
record_pos = renoise.song().transport.playback_pos -- position of where the recording is being started
renoise.song().transport:start_stop_sample_recording() -- starts recording
else
renoise.song().transport:start_stop_sample_recording() -- stops recording
renoise.app().window.sample_record_dialog_is_visible = false -- close record dialogue
renoise.song().transport.playback_pos = record_pos -- go to the start of the recording (unwanted?)
insert_recorded_instrument() -- insert note where the recording was started
disarm() -- disarms and quits
end
end
function insert_recorded_instrument()
renoise.song().patterns[record_pos.sequence].tracks[armed_track].lines[1].note_columns[1].note_string = "C-4"
renoise.song().patterns[record_pos.sequence].tracks[armed_track].lines[1].note_columns[1].instrument_string = string.sub(bit.tohex(renoise.song().selected_instrument_index-1), 7)
renoise.song().instruments[renoise.song().selected_instrument_index].samples[1].autoseek = true -- everyone wants this?
end
function disarm()
renoise.song().tracks[renoise.song().selected_track_index].color = trackcolor -- resets track color
renoise.song().transport.playing_observable:remove_notifier(notifier) -- cleanup
end
renoise.tool():add_menu_entry {
name = "Pattern Editor:Arm and record",
invoke = initialize
}
renoise.tool():add_keybinding {
name = "Pattern Editor:Record:Arm and record",
invoke = initialize
}