Find track of device

Hi,

I have an AudioDevice object and want to find its track. How to do that? Seems like I can’t compare the object with a trackDevice object directly…

This seems to be too few comparison then:

function EQHelper:findDeviceInTracks(device) 
  for _, track in pairs(sng.tracks) do
    if (track.type ~= renoise.Track.TRACK_TYPE_GROUP) then
      for _, trackDevice in pairs(track.devices) do
        if (device.display_name == trackDevice.display_name and device.device_path == trackDevice.device_path) then
          local isSame = true
          for x = 1, #device.parameters do
            if (device.parameters[x].value ~= trackDevice.parameters[x].value) then
              isSame = false
              break
            end
          end
          if (isSame == true) then
            return track
          end
        end
      end
    end
  end

  return nil
end

Would like to compare the object memory pointers directly or something… Maybe I already did that, but I forgot how.

local is_same = rawequal(one_audiodevice, another_audiodevice)

(personally, I would also overload the renoise classes with things like renoise.Track.track_index et c, just to compartmentalize and simplify code structure)

Ah thanks, can you give me an example how to overload the AudioDevice object, so it contains the track index and name? I printr-ed the audiodevice vs trackaudiodeivce objects, and they seem to be not the same, having different “userdata”.

The principle is found here (bottom example): Lua: Renoise.song().tracks[].members[].track_Index - #4 by taktik

When I was a bit deeper into Renoise API, I used to wrap my own object creation that also passed a .parent_object into all objects. Very neat and practical, but the syntax is not clear to my memory.

Hm, actually rawequal(device, trackDevice) works fine! Nice. Yeah providing some overloads to all those objects would be a good update. Also some oo-style stuff :stuck_out_tongue: which completely is missing now. device:getTrack() :stuck_out_tongue:

function findDeviceInTracks(device) 
  for _, track in pairs(sng.tracks) do
    if (track.type ~= renoise.Track.TRACK_TYPE_GROUP) then
      for _, trackDevice in pairs(track.devices) do
        if (rawequal(device, trackDevice)) then
           return track
        end
      end
    end
  end

  return nil
end
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.