Old 01-15-2022, 09:32 PM   #1
ndchong
Human being with feelings
 
Join Date: Sep 2019
Posts: 51
Default Script to select items in track xx

Hi there,
Anyone can help me with a script to select items in tracks 3,4 and 5?
Thanks
ndchong is offline   Reply With Quote
Old 01-16-2022, 05:59 AM   #2
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

Why particularly those tracks?

Anyhoo, there's a script (check out ReaPack ?)
Script: X-Raym_Add all items on selected track into item selection.lua

So just select the tracks you want (remembering you can do discontinuous selections)
and run it.
__________________
it's meant to sound like that...
jrk is offline   Reply With Quote
Old 01-16-2022, 08:13 PM   #3
ndchong
Human being with feelings
 
Join Date: Sep 2019
Posts: 51
Default

Thanks- that is what I was looking for.

I needed a one key push during live performance to select items on selected tracks and then pitch up 1 semi.

Thanks
ndchong is offline   Reply With Quote
Old 01-16-2022, 08:53 PM   #4
ndchong
Human being with feelings
 
Join Date: Sep 2019
Posts: 51
Default

Hmm still no go...

My custom action
Track Select track 3
Track Select track 4
Track Select track 5
Script: X-Raym_Add all items on selected track into item selection.lua
Track pitch up 1 semitone

But it only selects the last track which is 5.

I need to select track 3 4 and 5 all at the same time.

Last edited by ndchong; 01-16-2022 at 09:10 PM.
ndchong is offline   Reply With Quote
Old 01-16-2022, 10:36 PM   #5
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,230
Default

is this too slow?
Code:
Track Select track 3
Script: X-Raym_Add all items on selected track into item selection.lua
Track pitch up 1 semitone
Track Select track 4
Script: X-Raym_Add all items on selected track into item selection.lua
Track pitch up 1 semitone
Track Select track 5
Script: X-Raym_Add all items on selected track into item selection.lua
Track pitch up 1 semitone
there's also this action:
Code:
Item properties: Pitch item up one semitone
maybe try that in your original custom action instead of the track pitch?
babag is offline   Reply With Quote
Old 01-17-2022, 05:57 AM   #6
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Try this script:
Code:
local tracks_to_select = { 3, 4, 5 }

for i = 1, #tracks_to_select do
  local track = reaper.CSurf_TrackFromID( tracks_to_select[i], false )
  if not track then return reaper.defer(function() end) end
  tracks_to_select[i] = track
end

reaper.PreventUIRefresh( 1 )

reaper.SelectAllMediaItems( 0, false )

for i = 1, #tracks_to_select do
  for j = 0, reaper.CountTrackMediaItems( tracks_to_select[i] ) - 1 do
    reaper.SetMediaItemSelected( reaper.GetTrackMediaItem( tracks_to_select[i], j ), true )
  end
end

reaper.Main_OnCommand(40204, 0) -- Pitch item up one semitone


reaper.PreventUIRefresh( -1 )
reaper.UpdateArrange()
reaper.Undo_OnStateChange( "Pitch items up one semitone" )
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-18-2022, 12:21 AM   #7
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

Quote:
Originally Posted by ndchong View Post
Hmm still no go...
Your custom action selects track 3, then selects 4 (deselecting 3), and so on.
babag has the answer (above). Although it's not necessary to add the track items into a selection, if you're using track pitch (as babag hints)

amagalma's script also does the trick. Configuring the tracks to select in a list
"local tracks_to_select = { 3, 4, 5 }"

This will be useful when you have a requirement to select some other track set. And you will.

Incidentally, why use "CSurf_TrackFromID" rather than reaper.GetTrack()?

I wonder what the use case is for this? Obv, we're transposing - Perhaps there's a better way to do whatever it is that you're trying to do?
__________________
it's meant to sound like that...

Last edited by jrk; 01-18-2022 at 12:52 AM.
jrk is offline   Reply With Quote
Old 01-18-2022, 02:02 AM   #8
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Quote:
Originally Posted by jrk View Post
Incidentally, why use "CSurf_TrackFromID" rather than reaper.GetTrack()?
No reason, it's the same. It could be:
Code:
track = reaper.GetTrack( 0, tracks_to_select[i] - 1)
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-18-2022, 08:42 PM   #9
ndchong
Human being with feelings
 
Join Date: Sep 2019
Posts: 51
Default

Thanks a million guys.
Works now happy happy
ndchong 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 08:00 AM.


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