Here’s some code. When you run it and the selected track is a child of a group, it works.
But when you run it on a normal track, it gives an error.
local tri = renoise.song().selected_track_index
local tr = renoise.song():track(tri)
local function parent_index(t)
local i = 1
while renoise.song():track(t + i).type == 1 do
i = i + 1
local group_index = t + i
if tr.type == 1 and tr.group_parent then
I’m a bit confused. How can I tell if a track belongs to a group or it’s independent?
My experience: I ran into this yesterday. The problem is that group_parent does not return nil but is unavailable when there is no parent. I have suggested it to return nil (but maybe there is some basic lua way of handling this?) Otherwise you could iterate through tracks and make a map of the hierarchy or a simple check, using that to check if any track has tr as a member. I’d suspect this is getting fixed.
Yeah, we better wait. The same issue applies to .members. The only “workaround” I see is to create a group for every track on iteration and table.count members to see how many tracks to the left are part of the same group.
“group_parent” indeed always should be valid. Will fix that soon.
“members”, on the other hand only is and should be present for group tracks. Regular tracks can have no “members”. Check with “track(some_number).type == renoise.Track.TRACK_TYPE_GROUP” or type(some_track) == “GroupTrack”.
That magic “1” is a renoise.Track.TRACK_TYPE_SEQUENCER
Here is a temporary workaround for continuing on your project:
for tr = track+1, table.count(renoise.song().tracks) do
if renoise.song().tracks[tr].type == 4 and table.count(renoise.song().tracks[tr].members) >= tr - track then
Sorry for being such a pest, but magic number “4” is renoise.Track.TRACK_TYPE_GROUP.
This can be quite long to type, but you can create shortcuts to it then:
local TRACK_TYPE_GROUP = renoise.Track.TRACK_TYPE_GROUP -- somewhere at the top of the file
for i = track_index + 1, #renoise.song().tracks do
local track = renoise.song():track(i)
if (track.type == TRACK_TYPE_GROUP and #track.members >= i - track_index) then
Here is a snippet that returns the parent index to a track. It’s a bit tedious for a basic function imo
local s, parent_index = renoise.song(), nil
for i, track in ripairs(s.tracks) do
if track.type == renoise.Track.TRACK_TYPE_GROUP then
if i - #track.members <= track_index and track_index < i then
parent_index = i