Old 09-17-2021, 03:49 AM   #1
jtayl711
Human being with feelings
 
Join Date: Jul 2020
Posts: 102
Default Programmatically Change Track Routing

I'm trying to develop a web remote for musicians to select from a list of backing tracks and have their "more_me" tracks be dynamically routed to based on the active song selection.

For example, in Reaper I have track folders:

/BACKING_TRACK_STEMS
//SONG1
///SONG1_TR1
///SONG1_TR2
///SONG1_TR3
///ETC
//SONG2
///SONG2_TR1
///SONG2_TR2
///SONG2_TR3
///ETC

/MORE_ME_STEMS
//STEM1
//STEM2
//STEM3
//ETC

Upon selecting "SONG1" in the web interface, I'd like to clear any pre-existing routing going to MORE_ME_STEMS/STEM1,STEM2,STEM3,ETC and then route:

/BACKING_TRACK_STEMS/SONG1/SONG1_TR1 --> /MORE_ME_STEMS/STEM1
/BACKING_TRACK_STEMS/SONG1/SONG1_TR2 --> /MORE_ME_STEMS/STEM2
etc

I believe this is possible and I have a few ideas for how to do it but I'd like to hear opinions from more experienced programmers than myself.

I've only done ReaScript programming in .lua if that makes any difference.

Any suggestions? Is this possible?
jtayl711 is offline   Reply With Quote
Old 09-17-2021, 12:16 PM   #2
en5ca
Human being with feelings
 
Join Date: Dec 2018
Posts: 394
Default

Hi! From ReaScript documentation:

integer reaper.CreateTrackSend(MediaTrack tr, MediaTrack desttrIn)

See RemoveTrackSend, GetSetTrackSendInfo, GetTrackSendInfo_Value, SetTrackSendInfo_Value.

I think with those functions you should be able to manipulate track sends/routings programmatically.
en5ca is offline   Reply With Quote
Old 09-18-2021, 05:53 AM   #3
jtayl711
Human being with feelings
 
Join Date: Jul 2020
Posts: 102
Default

Thanks I’ll give it a shot
jtayl711 is offline   Reply With Quote
Old 09-18-2021, 06:51 PM   #4
jtayl711
Human being with feelings
 
Join Date: Jul 2020
Posts: 102
Default

So are send indices 0 based or 1 based? My script seems to keep crashing every time I go to remove the send.
jtayl711 is offline   Reply With Quote
Old 09-18-2021, 09:23 PM   #5
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 1,126
Default

One thing to keep in mind while deleting sends it that if you use a for loop, you always delete the first one. They are reindexed every time your delete one.
lexaproductions is offline   Reply With Quote
Old 09-19-2021, 07:26 AM   #6
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

When removing elements from an array you should loop backwards to avoid an invalid index.
Edgemeal is offline   Reply With Quote
Old 09-27-2021, 03:05 AM   #7
jtayl711
Human being with feelings
 
Join Date: Jul 2020
Posts: 102
Default

Quote:
Originally Posted by lexaproductions View Post
One thing to keep in mind while deleting sends it that if you use a for loop, you always delete the first one. They are reindexed every time your delete one.
This was it, thank you!
jtayl711 is offline   Reply With Quote
Old 09-27-2021, 03:06 AM   #8
jtayl711
Human being with feelings
 
Join Date: Jul 2020
Posts: 102
Default

Quote:
Originally Posted by Edgemeal View Post
When removing elements from an array you should loop backwards to avoid an invalid index.
Very good point, thanks!
jtayl711 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 05:39 AM.


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