Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 09-16-2015, 05:48 AM   #1
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default Anyone interested in doing a script (or two scripts) for this?

Iīm looking for scripts that would toggle the following actions:

1. Toggle Hide/Show all empty tracks
2. Toggle Hide/Show all tracks that donīt have a media item at the current cursor position (=to show only the tracks that have data at cursor position)

Anyone interested in doing this? Iīd be happy to pay for a custom build script. Maybe these actions would be interesting for the community as well (should help to keep things organized in larger templates).

Artie
Artie is offline   Reply With Quote
Old 09-16-2015, 06:04 AM   #2
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

That sounds relatively easy, I'll have a go.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-16-2015, 06:32 AM   #3
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default

Sounds great, thanks :-)
Artie is offline   Reply With Quote
Old 09-16-2015, 09:09 AM   #4
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Here's your first one: PL9-toggle hide empty tracks.

I'll modify it to a version that looks for items at the edit cursor later on

I've put plenty of comments in the script so you can see how it works. I take it you know how to load/run scripts?


Edit: I forgot to say that this requires the SWS extensions to function. Apologies.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.

Last edited by planetnine; 09-16-2015 at 12:39 PM. Reason: SWS Extensions...
planetnine is offline   Reply With Quote
Old 09-16-2015, 11:45 AM   #5
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default

Thanks very much Nathan,

just tested this, unfortunately it doesnīt quite work out the way I was hoping - it does indeed select all (and only the) empty tracks, but then it doesnīt hide them.
Iīm afraid Iīm totally ignorant when it comes to scripting, I think I understand the looping you do to select all empty tracks, but I donīt understand the command line you commented with "// toggle track hide".
What could I be doing wrong? I loaded up the script in the actions menu and just ran it as a whole. Correct?
Artie is offline   Reply With Quote
Old 09-16-2015, 12:37 PM   #6
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Hello Artie, I forgot to say that this script requires the SWS extension set to work.

If you haven't installed it, you ought to anyway, but it is needed for the toggle-hide command "SWS: Toggle selected tracks fully visible/hidden", and the command pair: "SWS: Save current track selection" and "SWS: Restore saved track selection". I used these in the script to save me wading through the track state to toggle the hidden status directly.


Here's your second one PL9-toggle hide no items cursor tracks.eel.

This also requires the SWS extensions to function.


>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 12:07 AM   #7
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default

Great, itīs all working! How can I show you my gratitude?

One more question though: Would it be possible to hide the tracks without having them go to selected state first? The thing is, this is meant to help organize larger templates. When I have really lots of tracks, it takes several seconds to loop and select them all first ... the command then becomes a bit slow.
Artie is offline   Reply With Quote
Old 09-17-2015, 12:39 AM   #8
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

I would have to access them directly in the Trackstate chunk (an XML chunk, similar to the project file describing the track in its entirety -can be quite large), and at this time, I don't know whether searching and changing it there would be quicker than than using selection and the SWS commands, Artie. I suspect it might be.

I'm just getting my head around the string functions in Lua, I will try to produce a Lua Trackstate chunk version and you can set them against each other to test. Lua is better equipped to deal with strings.


Just a point, is the script returning the original selection state after running?



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 12:42 AM   #9
G-Sun
Human being with feelings
 
G-Sun's Avatar
 
Join Date: May 2010
Location: Norway
Posts: 7,318
Default

Quote:
Originally Posted by Artie View Post
Great, itīs all working! How can I show you my gratitude?

One more question though: Would it be possible to hide the tracks without having them go to selected state first? The thing is, this is meant to help organize larger templates. When I have really lots of tracks, it takes several seconds to loop and select them all first ... the command then becomes a bit slow.
Custom action with save restore track selection will get you there. But I understand the request
__________________
Reaper x64, win 11
Composer, text-writer, producer
Bandcamp
G-Sun is offline   Reply With Quote
Old 09-17-2015, 12:45 AM   #10
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default

I think itīs probably the visual update of the UI that takes so long, it scrolls through all the tracks and highlights them (and pumps them up bolder) while selecting them.

Yeah, the script is returning to original selection state fine when I toggle it twice. (It deselects all tracks in reverse order, takes a couple of seconds as well)
Artie is offline   Reply With Quote
Old 09-17-2015, 12:51 AM   #11
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@planetnine
You should use PreventUIRefresh in your script to avoid UI refresh, it will be far more quicker

You may also consider saving and restoring track selection without SWS functions but with an table. You will then didn't have the need to llok at track state anymore.

Easier in Lua, but possible in EEL, as there would be only one table in the script

EDIT: Also, using IsTrackVisible function can be useful :P

Last edited by X-Raym; 09-17-2015 at 12:58 AM.
X-Raym is offline   Reply With Quote
Old 09-17-2015, 12:58 AM   #12
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Quote:
Originally Posted by G-Sun View Post
Custom action with save restore track selection will get you there. But I understand the request

It's built into the script GS, it saves and restores the track selection again afterwards...

Code:
Main_OnCommandEx(NamedCommandLookup("_SWS_SAVESEL"), 0, 0) ;// save current track selection
num_tracks = CountTracks(0); // count tracks in project
track_i =0; // start at track index 0
edit_cursor = GetCursorPosition(); // get edit cursor position in seconds
while (track_i < num_tracks) // loop through tracks...
(
	track_id = GetTrack(0, track_i); // track_id from track index
	SetTrackSelected(track_id, 1); // select track (only unselect if cursor conditions met)
	num_items = CountTrackMediaItems(track_id); // count media items in track
	num_items >0 ? // if media items...
	(
		item_i = 0; // set item index to 0
		while (item_i < num_items) // loop through items
		(
			item_id = GetTrackMediaItem(track_id, item_i); // get item id
			item_start = GetMediaItemInfo_Value(item_id, "D_POSITION"); // get item start in seconds
			item_end = item_start + GetMediaItemInfo_Value(item_id, "D_LENGTH"); // get item end in seconds
			(item_start <= edit_cursor) && (item_end >= edit_cursor) ? // check if item straddles cursor
			(
				SetTrackSelected(track_id, 0); // unselect track
				item_i = num_items; // to exit item check loop
			);
			item_i +=1; // next item index
		);
	);
	track_i +=1; // next track index
);
	
Main_OnCommandEx(NamedCommandLookup("_SWSTL_TOGGLE"), 0, 0); // toggle track hide
Main_OnCommandEx(NamedCommandLookup("_SWS_RESTORESEL"), 0, 0); // restore original track selection
The code is a bit "one step-at-a-time" for new-user legibility.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 01:11 AM   #13
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Quote:
Originally Posted by X-Raym View Post
@planetnine
You should use PreventUIRefresh in your script to avoid UI refresh, it will be far more quicker

You may also consider saving and restoring track selection without SWS functions but with an table. You will then didn't have the need to llok at track state anymore.

Easier in Lua, but possible in EEL, as there would be only one table in the script

EDIT: Also, using IsTrackVisible function can be useful :P

I was just looking at suspending the UI Refresh for speed.

I'm not looking at the hidden state Raymond, just toggling it. I did think it would be quicker, simpler and easier using actions. IsTrackVisible might be useful to stop the script hiding some tracks at the same time as restoring others because something was changed in the track (eg cursor position) between toggles eg If some tracks are already hidden, hide any new ones before unhiding the last lot?

I figured saving and restoring selection state with SWS would be quicker as it would be compiled code versus script. You think not?

The UI Refresh suspension is definitely necessary though...



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 01:24 AM   #14
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

IsTrackVisible may be useful for a SET version of this :P
If you already have track with empty items that are hidden, when executing your script, they will be visible again (which I guess may not be wanted). But this was just an idea

I don't think script code will be slower to run (the code will fit 5 lines maximum), but you can make benchmark using time_precise().
Save this in the variable at start of the the script, and make a subtraction at the end by calling the function a second time :P

But the real thing is to avoid scripts making unwanted action. The scrip is about toogle track visibility, not "ovveride my track selection slot". Breeder told me that was a really bad practice (and I use them it a lot of scripts for restoring all kind of stuff), so I end up coding my own save and restore functions (for view, cursor, item selection...). Finally, I find it far more user-friendly as there is no "hidden" behavior. (EDIT: I found his post and here)
Losing a track selection slot may be really unwanted, especially in Live situation.

The rest of your script is perfect !

Last edited by X-Raym; 09-17-2015 at 01:30 AM.
X-Raym is offline   Reply With Quote
Old 09-17-2015, 01:41 AM   #15
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Is there a SET version of IsTrackVisible? I scoured the API for alternate ways to do this.

If so, that would make life much easier as I understood the only way was to change things in the TrackStateChunk (and you have to be sure of your code to do that!).


There is IsTrackSelected and SetTrackSelected, why not SetTrackVisible to go with IsTrackVisible?



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.

Last edited by planetnine; 09-17-2015 at 05:30 AM. Reason: spelling
planetnine is offline   Reply With Quote
Old 09-17-2015, 01:50 AM   #16
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

Quote:
IsTrackVisible may be useful for a SET version of this :P
This reffer to the script you were building, sorry for the false hope ^^
But yes, track visible function could be handy !
X-Raym is offline   Reply With Quote
Old 09-17-2015, 01:54 AM   #17
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

I did search the API several times in the meantime, Raymond


Prevent UI refresh versions of those two scripts are in the stash Artie, see if they're any faster.

Working my way through the string wildcards in Lua, give me a while for a better version



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 02:29 AM   #18
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

PeventUIRefresh is actually a pretty high peformance booster, do you still feel the need to go to xml chunk ?
X-Raym is offline   Reply With Quote
Old 09-17-2015, 03:06 AM   #19
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

I want to learn Lua for XML manipulation anyway. I have EEL scripts that read BWF XML chunks, and I'd like to use the more powerful string manipulation of Lua for changing the XML.

All part of a plan ...



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 05:59 AM   #20
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default

Thanks so much for the effort, Nathan. It does indeed boost performance. (It still scrolls through the selected tracks visually though, only faster)

Just tested it with 300+ tracks, it takes about 7 seconds as opposed to about 22 seconds before.
But who would have so many tracks visible anyway, with about 100 tracks it takes a bit more than a second (before was about 5 seconds) which is good enough for me.

Can I offer you something for your effort?

Best,
Artie
Artie is offline   Reply With Quote
Old 09-17-2015, 06:19 AM   #21
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@planetnine

I manage to have pattern recognition for XML chunk SHOWINMIX infos in Lua :P

Code:
function Msg(variable)
  reaper.ShowConsoleMsg(tostring(variable).."\n")
end

track = reaper.GetTrack(0, 0)
retval, xml = reaper.GetTrackStateChunk(track, "", false)
Msg(xml)

answer1, answer2, answer3, answer4, answer5, answer6, answer7, answer8 = xml:match("SHOWINMIX ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)\n")
answer4 could be rename to TCP visibility, and return either 1 or 0 :P

Last edited by X-Raym; 09-17-2015 at 06:32 AM.
X-Raym is offline   Reply With Quote
Old 09-17-2015, 06:30 AM   #22
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by planetnine View Post
Is there a SET version of IsTrackVisible? I scoured the API for alternate ways to do this.



>
Yes

Code:
num_tracks = CountTracks(0); // count tracks in project
track_i =0; // start at track index 0
edit_cursor = GetCursorPosition(); // get edit cursor position in seconds
while (track_i < num_tracks) // loop through tracks...
(
  track_id = GetTrack(0, track_i); // track_id from track index
  num_items = CountTrackMediaItems(track_id); // count media items in track
  num_items > 0 ? // if media items...
  (
    item_i = 0; // set item index to 0
    while (item_i < num_items) // loop through items
    (
      item_id = GetTrackMediaItem(track_id, item_i); // get item id
      item_start = GetMediaItemInfo_Value(item_id, "D_POSITION"); // get item start in seconds
      item_end = item_start + GetMediaItemInfo_Value(item_id, "D_LENGTH"); // get item end in seconds
      (item_start <= edit_cursor) && (item_end >= edit_cursor) ? // check if item straddles cursor
      (
       // TCP
       GetMediaTrackInfo_Value(track_id, "B_SHOWINTCP") ? (   // is track visible in TCP ?
         SetMediaTrackInfo_Value(track_id, "B_SHOWINTCP", 0); // if visible -> hide the track...
       ) : (
         SetMediaTrackInfo_Value(track_id, "B_SHOWINTCP", 1); // ...else show track
       );
       
       // Mixer
       GetMediaTrackInfo_Value(track_id, "B_SHOWINMIXER") ? (   // is track visible in mixer ?
         SetMediaTrackInfo_Value(track_id, "B_SHOWINMIXER", 0); // if visible -> hide the track...
       ) : (
         SetMediaTrackInfo_Value(track_id, "B_SHOWINMIXER", 1); // ...else show track
       );
        item_i = num_items; // to exit item check loop
      );
      item_i +=1; // next item index
    );
  );
  track_i +=1; // next track index
);
UpdateArrange();            // update arrange view
TrackList_AdjustWindows(0); // update tracklist

spk77 is offline   Reply With Quote
Old 09-17-2015, 06:33 AM   #23
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@spk77

I bow down... you nailed it :P How could I missed it.

(don't forget prevent ui refresh )
X-Raym is offline   Reply With Quote
Old 09-17-2015, 06:44 AM   #24
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Maybe you have missed it because there's a little error in the reascript help file :

(see GetMediaTrackInfo_Value and SetMediaTrackInfo_Value in the help file)
Code:
.
.
.
P_ENV : read only, returns TrackEnvelope *, setNewValue= B_SHOWINMIXER : bool * : show track panel in mixer -- do not use on master
B_SHOWINTCP : bool * : show track panel in tcp -- do not use on master
B_MAINSEND : bool * : track sends audio to parent
.
.
.
spk77 is offline   Reply With Quote
Old 09-17-2015, 06:56 AM   #25
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Heh, I've just had this conversation with Justin in the Prerelease forum. Thanks anyway spk!


Just about to load up a re-write using SetMediaTrackInfo_Value SHOWINMIXER and SHOWINTCP...


Edit: I saved it as PL9-toggle hide no items cursor tracks2, so that Artie can compare speed on identical large projects between the Track-selection-SWS-toggle-hide method and this direct hide method.

I suspect that most of the time taken is scanning each track's media items for start and end points.




>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.

Last edited by planetnine; 09-17-2015 at 07:05 AM. Reason: Uploaded re-write
planetnine is offline   Reply With Quote
Old 09-17-2015, 07:03 AM   #26
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@spk77
Indeed !
but the thing is that I only search for the keyword VISIBLE which seems to be the official name of the thing... I would never have search for "showintcp" ^^


@planetnine


For the beauty of the sport, here the XML track modifications version, with GET and SET
answer4= 0 -- hidden
answer4=1 -- visible

Here a demo with first track of the project.

Note: it could more pretty but it works.

Code:
-- DEBUG FUNCTIONS
function Msg(variable)
  reaper.ShowConsoleMsg(tostring(variable).."\n")
end

reaper.ShowConsoleMsg("") -- Clean the console

-- GET THE TRACK
track = reaper.GetTrack(0, 0)

-- GET THE CHUNK
retval, xml = reaper.GetTrackStateChunk(track, "", false)
--Msg(xml)

-- PARSE SECTION
section = "SHOWINMIX"
answer1, answer2, answer3, answer4, answer5, answer6, answer7, answer8 = xml:match( section.." ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)\n" )

-- MODIFICATION
-- Don't forget to convert the result back to string.
answer4 = "1" -- 0 for hidden / 1 for visible

-- REPLACE THE LINE
csv = answer1 .. " " .. answer2 .. " " .. answer3 .. " " .. answer4 .. " " .. answer5 .. " " .. answer6 .. " " .. answer7 .. answer8 .. "\n"

xml = string.gsub(xml, "SHOWINMIX.+\n", "SHOWINMIX " .. csv)
--Msg(xml)

-- SET THE CHUNK
retval = reaper.SetTrackStateChunk(track, xml, false)

reaper.TrackList_AdjustWindows(0)
reaper.UpdateArrange()

Last edited by X-Raym; 09-17-2015 at 07:38 AM.
X-Raym is offline   Reply With Quote
Old 09-17-2015, 07:20 AM   #27
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

I didn't realise that your post was a modified version of my script spk, I was re-writing it anyway (mine is a little different to yours, hides both in MCP and TCP if either are visible).

Do you know if GetMediaTrackInfo_Value(track_id, "B_SHOWINTCP") is quicker than IsTrackVisible(track_id, 0) ...?


Raymond, this is the stuff I've spent half the day reading up in my "Programming in Lua" book. I've got quite a bit of script invested in reading BWF iXML tags in sound for picture, and renaming takes accordingly, etc. Be good to write some broad XML chunk toolkit functions to help other users read and write those Item and Track State Chunks. Good work, I'll be studying that tonight.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 07:38 AM   #28
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@planetnine
he he So I clean up the code a bit and I added more comments so you it is easier to understand.
I'll see how I can make it more flexible.

Here is a more flexible version (because you can just change the "section" name, and no need to adjust the variable number in most cases. Just a starting point for XML modifications, of course you will need to adjust it to your taste :P

Code:
-- DEBUG FUNCTIONS
function Msg(variable)
  reaper.ShowConsoleMsg(tostring(variable).."\n")
end

reaper.ShowConsoleMsg("") -- Clean the console

-- GET THE TRACK
track = reaper.GetTrack(0, 0)

-- GET THE CHUNK
retval, xml = reaper.GetTrackStateChunk(track, "", false)
--Msg(xml)

-- PARSE SECTION
section = "SHOWINMIX"
answer1, answer2, answer3, answer4, answer5, answer6, answer7, answer8 = xml:match( section.." ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)\n" )

-- MODIFICATION
-- Don't forget to convert the result back to string.
answer4 = "1" -- 0 for hidden / 1 for visible

-- REPLACE THE LINE
csv = answer1
if answer2 ~= nil then csv = csv .. " " .. answer2 end
if answer3 ~= nil then csv = csv .. " " .. answer3 end
if answer4 ~= nil then csv = csv .. " " .. answer4 end
if answer5 ~= nil then csv = csv .. " " .. answer5 end
if answer6 ~= nil then csv = csv .. " " .. answer6 end
if answer7 ~= nil then csv = csv .. " " .. answer7 end
if answer8 ~= nil then csv = csv .. " " .. answer8 end

csv = csv .. "\n"

xml = string.gsub(xml, section .. ".+\n", section .. " " .. csv)
--Msg(xml)

-- SET THE CHUNK
retval = reaper.SetTrackStateChunk(track, xml, false)

reaper.TrackList_AdjustWindows(0)
reaper.UpdateArrange()

Last edited by X-Raym; 09-17-2015 at 07:44 AM.
X-Raym is offline   Reply With Quote
Old 09-17-2015, 08:55 AM   #29
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by planetnine View Post
Do you know if GetMediaTrackInfo_Value(track_id, "B_SHOWINTCP") is quicker than IsTrackVisible(track_id, 0) ...?

>
I don't know...maybe IsTrackSelected, IsTrackVisible etc. are just wrapper functions?
spk77 is offline   Reply With Quote
Old 09-17-2015, 09:17 AM   #30
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Spk: Possibly...

Raymond: I'll have a look when I get back home. It looks good. Thanks for showing me some methods.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 09:30 AM   #31
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Quote:
Originally Posted by Artie View Post
Thanks so much for the effort, Nathan. It does indeed boost performance. (It still scrolls through the selected tracks visually though, only faster)

Just tested it with 300+ tracks, it takes about 7 seconds as opposed to about 22 seconds before.
But who would have so many tracks visible anyway, with about 100 tracks it takes a bit more than a second (before was about 5 seconds) which is good enough for me.

Can I offer you something for your effort?

Best,
Artie

Did you get to check the version2 with the direct (non-selecting) toggle hide?

Is it any faster on your projects? Maybe faster than 7 seconds?




>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-17-2015, 09:39 AM   #32
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

I ran into a problem with some zooming scripts that used track selection that should be considered in making scripts.

If the user has any track set to auto rec-arm, the script will trigger that on it's selection. The biggest problem that could result is if that track has some live input and monitoring on. Likely, this just scares the crap out of the user but there is is some potential for damaged equipment and or ears. (worst case scenario, however unlikely)

What I ended up doing was to first check the track chunk for the autorec arm state, if it was set, don't set it as selected. This slows down whatever you are doing though.

Would be nice to have something in the API to access this more quickly, so there can be better solutions.
James HE is offline   Reply With Quote
Old 09-17-2015, 09:40 AM   #33
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

@planetnine
IsTrackSelected and IsTrackVisible seem to be faster than getting values from GetMediaTrackInfo_Value(track, "param")

(I tested those two functions in Lua)
spk77 is offline   Reply With Quote
Old 09-17-2015, 11:51 PM   #34
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default

Nathan, thats it, itīs now down to just about over 2 seconds with over 300 tracks. With 100 tracks its almost instantenous!

Artie
Artie is offline   Reply With Quote
Old 09-18-2015, 12:04 AM   #35
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default

And, it doesnīt scroll through all the tracks visually anymore, selecting them one by one. Thatīs a big plus too - looked a bit weird before :-)
Artie is offline   Reply With Quote
Old 09-18-2015, 03:28 AM   #36
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Hello Artie...

I've converted the Toggle-hide empty tracks script to use direct toggle-hiding now instead of select and SWS-toggle-hide, and I think it is also much faster now: PL9 Toggle-hide empty tracks3

I've optimised the Toggle-hide track, no items at cursor script so that it stops checking items beyond the edit cursor, too, and it is noticeably faster still: PL9 Toggle-hide track, no items at cursor4 -see how it does on your 300 track test project


My test tracks for this are only just in double-numbers of tracks and a hundred items or so -continually toggling is now just a blurred flicker


Now, onto Raymond's Lua stuff for some crazy wav-file reading scripts...




>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-18-2015, 05:10 AM   #37
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@Planentine
Regardin what you have done in EEL, Lua will be a piece of cake for you :P
Can't wait to see what you have in mind !
X-Raym is offline   Reply With Quote
Old 09-18-2015, 07:06 AM   #38
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

It's just learning the syntax, I can already see that some of the more powerful functions will make my complex EEL scripts much tighter and easier to write.

It's just so slow at the beginning, referring-back to the book and the web reference all the time, making silly mistakes, writing more than is needed because I've not discovered the easier way of doing it.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-18-2015, 07:12 AM   #39
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@planetnine
Did you see my Lua video tutorials ?
Well they are pretty basic, but it is a quick jump into Lua for REAPER

The biggest thing for me in Lua compare to EEL are
  • Tables (Array and MultiDimensionnal)
  • String Operation
  • Files elative function (read, export etc...)
You will like it
X-Raym is offline   Reply With Quote
Old 09-18-2015, 08:04 AM   #40
Artie
Human being with feelings
 
Join Date: Sep 2015
Posts: 9
Default

Yeah everything is instantenous now!

But thereīs an issue with the "PL9 Toggle-hide track, no items at cursor4" now - it doesnīt seem to recognise item endings anymore. Lets say Iīve got an item from bar 3 to bar 5. Cursor in bar 2 - the action shows me nothing, as it should be. Cursor in bar 4 - the action shows me the item, as it should be. But when the cursor is in a later spot like bar 10, it still shows me the item from bar 3-5, and not only items that are in bar 10 ...
Artie 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:14 PM.


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