Old 12-17-2014, 03:59 PM   #1
little Ellison
Human being with feelings
 
Join Date: Jun 2014
Posts: 47
Default Track ID/index question

Hopefully a simple question - is the track index used in GetTrack a permanently unique ID for a track? Can I persist this value and use it to subsequently access tracks independent of what else may be done in reaper, such as things that could reorder the visible track sequence?

Or should I use the track GUID, and if so, I'd there a way to use it to get a track pointer? Maybe I missed something in the API doc...
little Ellison is offline   Reply With Quote
Old 12-17-2014, 10:37 PM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,992
Default

You need to use the track GUID if you want to keep track of tracks (no pun intended) that must be allowed to be reordered by the user etc...The track "ID" is just the current index number of the track and will change when the track is moved.

There doesn't appear to be an API function to get a track pointer from a GUID. You can of course write that yourself by iterating over the project tracks and comparing the GUID. (If this sounds algorithmically bad, you should benchmark how it works out, instead of trying to prematurely come up with some more complicated solution to "optimize" it. edit: Looks like a std::map based lookup is can be beneficial to performance when there are LOTS of tracks. However, this has the problem that you need to have the map kept up to date...So you either need to generate the map anew each time before you do lots of iterations on it or some hack that checks if the map contents correspond to what is in the Reaper project currently etc...)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 12-18-2014 at 12:38 AM.
Xenakios is online now   Reply With Quote
Old 12-18-2014, 05:22 AM   #3
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,992
Default

Some code I wrote to deal with this :

http://pastebin.com/wBszgP31

(Remember to #include <map> #include <algorithm> etc)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 12-18-2014, 02:30 PM   #4
little Ellison
Human being with feelings
 
Join Date: Jun 2014
Posts: 47
Default

'...instead of trying to prematurely come up with some more complicated solution to "optimize" it...'

You must know me from somewhere...


I was coming to that conclusion,that GUID was the unique id, but no lookup api for it. Thanks for posting the code, will download when I get back on my computer.

Anyway, thanks again, and cheers!

Last edited by little Ellison; 12-19-2014 at 01:05 AM.
little Ellison is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.