Old 05-12-2021, 05:02 PM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,232
Default count visible tracks?

i know there's this
Code:
reaper.CountSelectedTracks( 0 )
but is there an equivalent for visible tracks?

thanks,
babag
babag is offline   Reply With Quote
Old 05-12-2021, 06:25 PM   #2
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

reaper.CountTracks( proj ) ???
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-12-2021, 07:10 PM   #3
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,232
Default

thanks musobob. won't that just give me that total number of tracks? i'm trying to get the number of VISIBLE tracks. or does that not count hidden tracks?

thanks again,
babag
babag is offline   Reply With Quote
Old 05-12-2021, 07:28 PM   #4
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

retval, flags = reaper.GetTrackState( track )

Gets track state, returns track name.
flags will be set to:
&1=folder
&2=selected
&4=has fx enabled
&8=muted
&16=soloed
&32=SIP'd (with &16)
&64=rec armed
&128=rec monitoring on
&256=rec monitoring auto
&512=hide from TCP
&1024=hide from MCP
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-12-2021, 08:32 PM   #5
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

See if this gives you what you need:
Code:
function Msg(str)
  reaper.ShowConsoleMsg(tostring(str).."\n")
  
end

 hidden_tracks_512 = 0
 hidden_tracks_1024 = 0

 track_count = reaper.CountTracks( 0 )
 Msg("Tracks "..track_count)
 for i = 1, track_count do
 
   track = reaper.GetTrack( 0, i-1 )
   
   retval, flags = reaper.GetTrackState( track )
   
   Msg("Flag "..flags)
   
   if flags == 512 then
     
     hidden_tracks_512 = hidden_tracks_512 +1
   end  
   if flags == 1024 then
     
     hidden_tracks_1024 = hidden_tracks_1024 +1
   end   
 end 
 
 visable_tracks = track_count - (hidden_tracks_512 + hidden_tracks_1024)
 
 Msg( "&1024=hide from MCP "..hidden_tracks_1024 )
 
 Msg( "&512=hide from TCP "..hidden_tracks_512)
 
 Msg( "visable_tracks "..visable_tracks)
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 05-12-2021 at 09:10 PM.
MusoBob is offline   Reply With Quote
Old 05-13-2021, 11:12 AM   #6
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,232
Default

oh, wow! thanks for this. i was hoping for something simpler like a native call that would return something simple. will try this soon.

i also found 'reaper.GetMediaTrackInfo_Value' which has an option for:

Code:
B_SHOWINTCP : bool * : track control panel visible in arrange view (do not use on master track)
i got something working using that.

thanks again, MusoBob. the help is much appreciated!
babag

edit:
here's an excerpt of what i have using GetMediaTrackInfo_Value:
Code:
        local TrxTotal = reaper.CountTracks( 0 )

        totalVis             = 0

        for i                = 0, TrxTotal - 1 do                -- loop through tracks

            local TrxVis     = reaper.CountSelectedTracks( 0 )   -- set variable for number of selected tracks in current project ( 0 )

            local TrkCurr    = reaper.GetTrack( 0, i )           -- set variable for current track
            local Visible    = reaper.GetMediaTrackInfo_Value( TrkCurr, "B_SHOWINTCP" )

            if Visible       == 1 then
                totalVis     = totalVis + 1
            end
            
        end

Last edited by babag; 05-13-2021 at 11:40 AM.
babag is offline   Reply With Quote
Old 05-13-2021, 12:19 PM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

When using Ultraschall-Api, you can use GetAllVisibleTracks_Arrange, which also allows you to choose, whether tracks must be fully visible or can be partially visible as well and the option to include the MasterTrack:

https://mespotin.uber.space/Ultrasch...Tracks_Arrange
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-13-2021, 12:25 PM   #8
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,232
Default

interesting. thanks!
babag 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:59 PM.


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