Old 09-22-2018, 07:46 PM   #1
jmarchuk
Human being with feelings
 
Join Date: Mar 2017
Posts: 12
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: 2,304
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 online now   Reply With Quote
Old 09-22-2018, 08:24 PM   #3
jmarchuk
Human being with feelings
 
Join Date: Mar 2017
Posts: 12
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
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 587
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?
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: 7,451
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
__________________
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
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:22 PM.


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