Old 09-22-2018, 07:46 PM   #1
jmarchuk
Human being with feelings
 
Join Date: Mar 2017
Posts: 15
Default GetSelectedTrack won't return a MediaTrack?

so I have:

Code:
for i = 0, totalTracks-1 do
    track = reaper.GetSelectedTrack(0,i)
    reaper.SetMediaTrackInfo_Value(track, "I_RECMODE", 3) 
--etc...
and I get an error when trying to run the script saying "bad argument #1 to 'SetMediaTrackInfo_Value' (MediaTrack expected)".

So what I'm seeing here is that the variable 'track' isn't a MediaTrack, but I've no clue why that would be.
jmarchuk is offline   Reply With Quote
Old 09-22-2018, 07:55 PM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

You can tell what track is with:
Code:
reaper.ShowConsoleMsg(string.format('track = %s\n', track))
Is totalTracks the number of selected tracks (not all tracks)? A common cause would be the index is out of range and GetSelectedTrack returns nil.
cfillion is offline   Reply With Quote
Old 09-22-2018, 08:24 PM   #3
jmarchuk
Human being with feelings
 
Join Date: Mar 2017
Posts: 15
Default

Quote:
Originally Posted by cfillion View Post
You can tell what track is with:
Code:
reaper.ShowConsoleMsg(string.format('track = %s\n', track))
Is totalTracks the number of selected tracks (not all tracks)? A common cause would be the index is out of range and GetSelectedTrack returns nil.
That was the problem! totalTracks was the number of tracks in the project, not the selected tracks. Works like charm now, thank you
jmarchuk is offline   Reply With Quote
Old 09-23-2018, 08:26 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by cfillion View Post
You can tell what track is with:
Code:
reaper.ShowConsoleMsg(string.format('track = %s\n', track))
Is totalTracks the number of selected tracks (not all tracks)? A common cause would be the index is out of range and GetSelectedTrack returns nil.
Holy Shit, this works? Without having to use statechunks and such?
Meo-Ada Mespotine is offline   Reply With Quote
Old 09-25-2018, 11:18 AM   #5
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by mespotine View Post
Holy Shit, this works? Without having to use statechunks and such?
It works to check what the pointer value is for the track, nothing else.

Code:
track = userdata: 0000000002F47B50
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios 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 12:58 AM.


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