If I have two tracks with their default names (Track01 and Track02) and I also have a notifer for each track.name_observable which prints out “Name changed” followed by the tracks name (the new one, I guess), followed by a print(track) then I get the following when swapping:
Name changed
Track 01
userdata:0x0xbedd9d4
Name changed
Track 01
userdata: 0x0xbedfb3c
Now, something is wrong here: Where is Track 02??? Why are both tracks named to ‘Track 01’? I clearly see the second one being named ‘Track 02’ in the GUI.
What is going on here???
It doesn’t look like both tracks are named 01 but only the address of track01 changed.
Though it is not clear to me here wether or not you were using a routine to print all tracknames when such events happen or you are just simply printing the name of the first track, In the first case you should be able to clearly see all relations here.
Also stuff happens with default track names if you would remove one of these tracks. (if you remove track07, track08 instantly becomes track07)
as I said, I am attaching a notifier to each tracks track.name_observable that prints out its name, and its address, everytime it’s name is changed. (so the first case you mentioned).
If I do the same with with custom track names (“a” and “b” for instance), then it correctly prints
a
b
so the new names of the tracks!
I don’t really see what is going on here with internal names, but I assume they are not just renamed when being swapped!
That is why I am asking.
Okay, here is exactly what I am doing on loading a song:
local function add_notifier_to_tracks(song)
for track=1,#song.tracks do
song.tracks[track].name_observable:add_notifier(function()
local self = song.tracks[track]
print("Name changed")
print(self.name)
print(self)
end
)
end
end
Maybe it goes wrong when adding the local self, but I could not figure out how else a Track can reference to itself!
Let me clarify it even further:
I assumed that when swapping tracks with default names that would trigger the following 3 steps internally:
Swap positions in renoise.song().tracks
rename tracks[1] (the old Track 02) to Track 01
rename tracks[2] (the old Track 01) to Track 02
But apparently this is not the case. So what does happen?
After some testing they are renamed when swapped. Tracks having their default name will always be named to the position that they form.
If you don’t want that, make sure each track has a name that is not the default name structure and all should be fine. (You could add an underscore or dot to each track that is still having their default name)