T7 Demo: Scripting Help

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

Post

I'm playing around with the script editor and it's working really great. I wonder if there is a document that lists all of the various targets and properties and similar? If not, there probably should be.

Image

What I intend to do, to get a feel for it, is to write code like above to do things like strip all numerics, prepend with numbers (1-,2-, etc), parse and correct case (bass to Bass, etc) and some other things like that. I know JS well enough, I just don't know what's exposed there to target, like track color or other similar things.

Thanks.

P.S. I'm also curious how to address the full track collection instead of only selected tracks like above.

Post

Unless they're listed in Bill's T7 manual, the only place is the Keyboard Shortcuts, where you've been editing your script. There was a long thread about scripting not so long ago, which might help a bit: viewtopic.php?f=22&t=441475

And a video made by one of our co-users: viewtopic.php?f=22&t=460638
Last edited by jabe on Tue Apr 19, 2016 3:03 pm, edited 1 time in total.
[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

Yeah. I guess I'll have to look at every sample script to find out.

On another note, it seems that the JS implementation isn't full. My replace code for example doesn't work, doesn't do anything in the script editor... like below... assuming trackName is a valid string...

trackName = trackName.replace([0-9],' ')
Last edited by LawrenceF on Tue Apr 19, 2016 3:06 pm, edited 1 time in total.

Post

LawrenceF wrote:Yeah. I guess I'll have to look at every sample script to find out.

On another note, it seems that the JS implementation isn't full. My RegEx code for example doesn't work, doesn't do anything in the script editor.
The TSC people are generally amenable to suggestions. I don't know whether we have any Javascript experts among the users.
[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

LawrenceF wrote:Yeah. I guess I'll have to look at every sample script to find out.
We do have a list of improvements to make to the macros feature, one of which is providing a more detailed function library and documentation. I'm not sure exactly when we'll be able to deliver this however but it is being thought about.
LawrenceF wrote:On another note, it seems that the JS implementation isn't full. My RegEx code for example doesn't work, doesn't do anything in the script editor... like below...

trackName = trackName.replace([0-9],' ')
Yes, this isn't a full Javascript implementation although it does cover most of the basic language features and containers. For a full run down of the capabilities check out the source code: https://github.com/julianstorer/JUCE/bl ... vascript.h

Post

(@jabe before I saw db's reply)

Yes, maybe someone can figure it out, maybe my code is wrong but the replace line below doesn't work no matter how I format it. I also tried new(RegEx) to no avail, so if regular expressions work in JS here, an example would be nice.

Code: Select all

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

for (i = 0; i < tracks.length; i++){
			
		// get the current track name 
    	var trackName = Tracktion.getName (tracks[i]); 

		// this passes the check but doesn't work
		// trying to strip numeric chars from name
		var	newName = trackName.replace([0-9], '');
	
		Tracktion.showMessage (newName);

}  // end tracks
Also, I see how this function below returns all the tracks in the project, not just selected tracks...

Code: Select all

tracks = Tracktion.getEditElements ('track');
... but I'm not sure how when iterating that collection to skip over the Marker & Tempo tracks in this case, since those can't be renamed.
Last edited by LawrenceF on Tue Apr 19, 2016 3:25 pm, edited 1 time in total.

Post

dRowAudio wrote:Yes, this isn't a full Javascript implementation although it does cover most of the basic language features and containers. For a full run down of the capabilities check out the source code: https://github.com/julianstorer/JUCE/bl ... vascript.h
Thanks a lot DB, I'll have a look. Some random suggestions...

- Indenting: It's a little annoying for more complex scripts to have to keep tabbing over to keep the indented code structure. Perhaps make returns respect the current indenting and have two returns (paragraph) go all the way back. Also, it would be nice to indent a full selection instead of erasing it with TAB, to select a block of code and TAB -> indent the full selection.

- Prompt: This thing is begging for a prompt for user interaction. For example, my RegEx experiment here might prompt the user to do any one of multiple things, like Cap names, strip numbers, Prefix numbers, depending on what the return value or what the user chooses.

If you could build in a generic UI prompt, that would be great. For example...

Code: Select all

var retval = prompt("Action1","Action2","Action3")   (prompts are buttons maybe?)

if (retval = "Action1"){

}
Also, here on Win 8 I noticed that some errors are really slow being parsed as the code tries to check the formatting or validity of the code, really long pauses while you wait for the check to go Checkmark or X. I assume in those cases it's cross checking against something before validating or not, but some of those pauses take many long seconds. I wonder if (going forward) that could be more efficient, faster.

Post

Here's kinda what I had in mind above...

Code: Select all

	// *** fake  return values from an input box or dialog
	var retval = "Strip Numbers";
	var doClips = false;

	/* get the collection of all tracks in the project
	** this also includes tempo and marker tracks ** */
	var tracks = Tracktion.getEditElements ('track');

	var curTrack = 0; // init the track start index 
	
	// Track Collection ********************************************
	while (curTrack < tracks.length){

			// get the name of the current track if you need it
			var trackName = Tracktion.getName (tracks[curTrack]);

	/* here we might want to parse a return value from the user to
	know what to do, to strip numbers or prefix numbers or do some
	other things like check formats for first caps, if there was some
    way to get user input via a dialog that runs when the script intis.
	below is using the currently faux return values */

    if (retval == "Strip Numbers"){

    	// regex strip all numbers from trackName and replace it

	} else if (retval == "Check Format"){
	
    	// reformat with first letter caps and replace it

	} else if (retval == "Prefix #"){
	
    	/* prefix incremental "# - " to track names so that stem
		exports will line up correctly on the file system */
    
    } else {

		// do nothing?  stop executing script, cancel?
		// maybe force throw an error to stop execution
	
	} // end track name formatting options


			// =====================================================
            // maybe also do stuff to clips while we're here already 
			// =====================================================

			// get the collection of clips on the current track
			var clips = Tracktion.getSelectedEditElements ('clip');
			var curClip = 0;  // init or reset clip index 

			// only proceed if the current track has clips on it
			// and the doClips boolean var is true
			// assume it will bypass marker and temppo tracks??
			if (clips.length > 0  && doClips = true){
  
					//  Clip Collection ----------------------------
					while (curClip < clips.length){	

					// maybe also rename the clips after the new track names

					curClip++; // increment the clip index
					}	
					// --------------------------------------------- 

          	} 
			// =====================================================
			// end of section to potentially do something to  clips
			// =====================================================


	curTrack++; // increment the track index
	}
  	// *************** end track collection *********************

Post

Can someone at a minimum document the properties and formatting for this function below? I have no idea and can't find any examples of it in use in any of the thread samples...

var property = tracks[0].getProperty ('propertyName');

What things can be used for the propertyName value above and how?

Thanks.

Post

I am not sure if this what you mean but I hope this help this is the Macro to my Master Fader track with the Track named.

for (var i = 1; --i>= 0;)
{
var track =Tracktion.insertTrack ('audio');
Tracktion.setName (track, "MASTER FADER");
Tracktion.insertPlugin (track, 'T-RackS CS Metering', 0, 'VST');
Tracktion.insertPlugin (track, 'Sonalksis FreeG Stereo (64 bit)', 0, 'VST');
Tracktion.insertPlugin (track, 'T-RackS CS Brickwall Lim', 0, 'VST');
Tracktion.insertPlugin (track, 'T-RackS CS Master EQ 432', 0, 'VST');
Tracktion.insertPlugin (track, 'Limiter6-x64', 0, 'VST');
Tracktion.insertPlugin (track, 'T-RackS CS Bus Comp', 0, 'VST');
Tracktion.insertPlugin (track, 'T-RackS CS Prog EQ 1A', 0, 'VST');
Tracktion.insertPlugin (track, 'IIEQPro', 0, 'VST');
Tracktion.insertPlugin (track, 'Scarlett Reverb 64', 0, 'VST');


}

Tracktion.showMessageAboveProperties ('MASTER FADER')

Post

Thanks a lot, that's really useful for plugins.

I was more looking for examples of that other specific function. Nothing I use there guessing ('name') (or mute or anything else I try) validates or works and I can't find any code examples using it.

I assume get / set "named property" would cover all of the most typical or common properties for an object like name, mute, solo, etc, etc, but I have no idea how to format it. The raw example seems to mean they're string format, the targets, but nothing works because (I guess) I don't know how to format it.

My guess would be something like if the object was a track... Track.getProperty('isSolo') ... would return a bool or something maybe but nothing I try there ever validates in the editor.

Post

I get you now, I only basically modified Macro's that where present in Tracktion. I am know way a person who is a professional in writing code but I do a little bit here and there for my website.

Post

Thanks a lot anyway. Neither am I, anything close to a pro, far from it.

I wish they'd document some of that though because my guesses are missing the mark.

Post Reply

Return to “Tracktion”