Macro javascript problem

Discussion about: tracktion.com
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi dRowAudio (or any one else), I wonder if you can tell me why javascript such as the following doesn't work. To me it looks ok but the editor won't accept it. Does the getProperty method only work in certain circumstances?

Code: Select all

var tracks = Tracktion.getSelectedEditElements ('track');
var track = tracks[0];
if (track.getProperty ('name') == 'Guitar')
	Tracktion.showMessage ('Guitar');
Also, how would I go about getting a list of all plugins on a track and is it possible to select a track without selecting another object like a plugin or clip first.

Post

okay first I wish I could help with Macro's issue but I only know how to do the basic things like load up plugins, but yes you can select tracks only and your plugins can't be viewed by track but in the cpu tab you can see a list of every plugin in the edit there is a option to group by track but it will only show the track name, cpu and latency sum for that whole track and you can select it and select the option show selection in edit and this will select the track only also. You can select a track with a Midi controler, macro, or mouse by clicking on the track on the left side of the track were the track name is located after selecting any track or plugin you can now navigate by holding alt and pressing the arrow keys to move up and down the tracks and also go up an down left and right from track to track selecting plugins once you select a plugin I hope this helps.

Post

AGreen wrote:Hi dRowAudio (or any one else), I wonder if you can tell me why javascript such as the following doesn't work. To me it looks ok but the editor won't accept it. Does the getProperty method only work in certain circumstances?

Code: Select all

var tracks = Tracktion.getSelectedEditElements ('track');
var track = tracks[0];
if (track.getProperty ('name') == 'Guitar')
	Tracktion.showMessage ('Guitar');
Also, how would I go about getting a list of all plugins on a track and is it possible to select a track without selecting another object like a plugin or clip first.
Puzzled here. I couldn't get

if (track.getProperty ('name') == 'Guitar')

accepted. It did accept

if (track.getName == 'Guitar')

but the value of track.getName was always "undefined".
[W10-64, T5/6/7/W8/9/10/11/12/13, 32(to W8)&64 all, Spike],[W7-32, T5/6/7/W8, Gina16] everything underused.

Post

Thanks lay it, but I'm trying to select tracks by macro.

Post

jabe wrote:
Puzzled here. I couldn't get

if (track.getProperty ('name') == 'Guitar')

accepted. It did accept

if (track.getName == 'Guitar')

but the value of track.getName was always "undefined".
Yes jabe, there seem to be some funny things going on. Some statements will work in a for loop but not as a single line which is very odd. The getProperty statement seems to be an example of that. We really need a list of methods and their usage because otherwise we're working blind. The following works by the way:

Code: Select all

var tracks = Tracktion.getSelectedEditElements ('track');

for (var i = 0; i < tracks.length; i++){
	var track = tracks[i];
    if (track.getProperty ('name') == 'Guitar')
		Tracktion.showMessage ('Guitar');
}

Post

The Tracktion.showMessage() bit isn't showing a message here, unless I'm looking in the wrong place.
[W10-64, T5/6/7/W8/9/10/11/12/13, 32(to W8)&64 all, Spike],[W7-32, T5/6/7/W8, Gina16] everything underused.

Post

jabe wrote:The Tracktion.showMessage() bit isn't showing a message here, unless I'm looking in the wrong place.
It should show up next to the mouse if the track is named "Guitar" and it's selected.

Post

I can confirm this is a bug. I think it's a parse error (which stems from the fact that the script is parsed when typed slightly differently to when it's actually run as obviously there won't be any selected tracks or objects returned so we have to create dummy objects with the various methods on them e.g. the getProperty/setProperty methods).

I think what's happening is that getSelectedEditElements is supposed to return an array but when parsed it's actually returning just a single dummy object. I'm not sure exactly why using it in a loop works though, it might just be that the parser can't keep up or the call to .length is actually turning it in to an array.

I think I've got a fix for this now though so will do some tests and hopefully the fix will make it in to 8.1.1.

Post

Ok dRow thanks for that. I'll just use the for loop work around for now.

Post

AGreen wrote:
jabe wrote:The Tracktion.showMessage() bit isn't showing a message here, unless I'm looking in the wrong place.
It should show up next to the mouse if the track is named "Guitar" and it's selected.
I put that line on its own in a macro and caught the bubble with it in. Thanks.
[W10-64, T5/6/7/W8/9/10/11/12/13, 32(to W8)&64 all, Spike],[W7-32, T5/6/7/W8, Gina16] everything underused.

Post Reply

Return to “Tracktion”