Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- /song/track/XXX/send_switch
-- see http://neurogami.com/blog/neurogami-renoise-send-track-scripting-with-osc.html
add_track_action {
pattern = "/send_switch",
description = "Change the receiver of the track's send device.\n" ..
"Requires you follow a naming convention",
arguments = { argument("send_index", "number") },
handler = function(track_index, send_index)
local device_index
local device
print( ( "Triggered /song/track/XXX/send_switch for track index %d, send index %d"):format(track_index, send_index) )
local tracks = song().tracks
if ( send_tracks == nil ) then
print("Go get send tracks")
send_tracks = {}
send_track_count = 0
for i = 1,#renoise.song().tracks do
if renoise.song().tracks[i].type == renoise.Track.TRACK_TYPE_SEND then
send_track_count = send_track_count + 1
print("Storing send track: " .. renoise.song().tracks[i].name)
send_tracks[send_track_count] = renoise.song().tracks[i]
end
end
else
print("send_tracks = ")
print(send_tracks)
end
if (track_index > 0 and track_index <= #tracks) then
print("Found the track!")
local send_device = nil
local devices = tracks[track_index].devices
if (#devices > 0 ) then
local i, j
for device_idx, device in ripairs(devices) do
print(device.display_name)
i, j = string.find(device.display_name, "send_")
if i == 1 then
local send_tag = string.gsub(device.display_name, "send_", "")
print("Found a send device with tag " .. send_tag )
send_device = device
local idx
print( ("We have %d send tracks"):format(send_track_count ) )
local match_count = 0;
for idx = 1, send_track_count do
print("Check name of send track '" .. send_tracks[idx].name .. "' for '" .. send_tag .. "'")
i, j = string.find( send_tracks[idx].name, send_tag)
if i then
match_count = match_count + 1
print("- - - - - - We have a send track tag match on send track " .. send_tracks[idx].name )
print(("Matched send track is idx %d and match_count %d "):format(idx, match_count) )
if match_count == send_index then
for __,param in ipairs(device.parameters) do
print(param.name)
if param.name == "Receiver" then
param.value = idx-1
print("Updated value of device " .. device.display_name )
break
end
end
break
end
end
end
break
end
end
end
else
print("That index is out of range: %d"):format(track_index)
end
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.