Javascript Macro Action Requests

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

Post

lay it prodctions wrote:Is there a way to make a selected Clip mono with a macro?
Do you mean to simply change disable the right channel or render the clip to a mono version?

Post

dRowAudio wrote: Do you mean to simply change disable the right channel or render the clip to a mono version?
I mean to render the clip.

Post

I could have sworn that I had used the string method substr() in a script, but now I get a notification that it is an unknown function. Any ideas? Am I making a mistake?

Post

Rock wrote:I could have sworn that I had used the string method substr() in a script, but now I get a notification that it is an unknown function. Any ideas? Am I making a mistake?
I don't think we have the shortened "substr" method, try "substring" instead?

Post

Is there a way to call up the mixer page using a macro? Also is there a macro for the second method the holding shift and pressing the mixer button option?

Post

Code: Select all

Tracktion.toggleVisibility ('mixer');
will toggle the mixer panel. Currently there is no macro to do the shift functionality because what that really does is the following:
1) Opens a the current Edit as a Mixer tab
2) Closes the existing tab

We don't currently have macros to open/close Edits so this won't be possible. I'll add it to the list though as we might be able to make it work in the future.

Post

Is there a way to get a track's input device's name?

Post

Rock wrote:Is there a way to get a track's input device's name?
Not at the moment. Input devices live in their own bit of the Edit XML and their's currently no accessors for it. It is on the list of methods to add though so hopefully soon.

Post

Yesss I found it, I need those clip selection options (you know, the ones you find when you select a slip and then there is that drop down for select clips..)
*select all later clips in the same track
*select all clips later than the cursor position in all track etc.
just put them all in!

Post

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
Request to make visible status of panels available e.g. ...

Code: Select all (#)

if(Tracktion.isVisible ('controlsPanel')) {
 ...
}
... or to have toggleVisibility take another argument to force the result you want e.g. ...

Code: Select all (#)

Tracktion.toggleVisibility ('controlsPanel',false); // force hide
Tracktion.toggleVisibility ('controlsPanel',true); // force show

Post

Hi all,

I'm just beginning to look at this and try to learn a bit about the syntax, available methods, etc. I went through the thread and tried to collect all of the "proven" working scripts and pulled them together into one spot for study and reference. These are all just individual bits and pieces.

In case it's a help to anyone, here they are below. Maybe it can be posted somewhere?


//Create a track named X
//Rewind X amount
//Load plugin with preset X

// Insert a Track Named X
var track = Tracktion.insertTrack ('audio');
Tracktion.setName (track, "New Track Name");

// Rewind X Amount
var currentPos = Tracktion.getPosition ('transport');
Tracktion.setPosition ('transport', currentPos - 10.0);

//applying a preset to a plugin
// Insert Plugin With Preset
var track = Tracktion.getTrackFromSelectedObject();
var plugin = Tracktion.insertPlugin (track, "Massive", 0, "AudioUnit");
var preset = Tracktion.getPresetFromLibrary ("Massive All Souls");
Tracktion.setPluginPreset (plugin, preset);

//adding a preset directly
// Insert Named Preset
var track = Tracktion.getTrackFromSelectedObject();
var preset = Tracktion.getPresetFromLibrary ("Massive All Souls");
Tracktion.insertPluginPreset (track, preset);


//NEXT SCRIPT

//For renaming tracks you can do this like so:

var tracks = Tracktion.getSelectedEditElements ('track');
Tracktion.setName (tracks[0], 'Kick');
Tracktion.setName (tracks[1], 'Snare');
Tracktion.setName (tracks[2], 'Hats');

// etc. Or you could start with the first track and use "Tracktion.selectItem ('down')" as in your example.

//NEXT SCRIPT

//As most users simply need a way to change to a specific tab quickly I've added methods
//to get the current tab index and to change it by a delta.
//This should mean you can quickly add shortcuts for previous/next tab or jump to a specific tab index. E.g.

// Jump to tab 2
var index = Tracktion.getWindowTabIndex();
var delta = 2 - index;
Tracktion.changeWindowTabIndex (delta);

//NEXT SCRIPT


//You can now add the clip types: 'barsBeatsMarker' & 'absoluteMarker'.
insertClip also returns an object so you can rename it or move it around etc.
// Insert Bars/Beats Marker Clip
var clip = Tracktion.insertClip ('barsBeatsMarker');
Tracktion.setName (clip, "Hello world!");

//NEXT SCRIPT

//So you can scroll through which active automation line shows on the track.

//Next Active Automation Parameter
var track = Tracktion.getTrackFromSelectedObject();
Tracktion.changeActiveAutomationParameter (track, 1);

//NEXT SCRIPT

// Reset Tracks Solo/Mute
var tracks = Tracktion.getEditElements ('track');
Tracktion.setSolo (tracks, false);
Tracktion.setSoloIsolate (tracks, false);
Tracktion.setMute (tracks, false);

//NEXT SCRIPT

//Renames all clips on a selected track to match the track name
// Rename Clips From Track
var tracks = Tracktion.getSelectedEditElements ('track');

for (var i = 0; i < tracks.length; ++i)
{
var track = tracks;
var trackName = Tracktion.getName (track);
var clips = Tracktion.getClipsFromTracks (track);

for (var c = 0; c < clips.length; ++c)
{
var clipName = trackName + " " + (c + 1);
Tracktion.setName (clips[c], clipName);
}
}

//Possible rework to name a track based on a Clip??
// Rename Track from Clip
for (var i = 0; i < tracks.length; ++i)
{
var track = tracks;
var clips = Tracktion.getClipsFromTracks (track);
var clipName = Tracktion.getname(clips[clip.length - 1]);
Tracktion.setName (track, clipName);
if (clips.length >1){
Tracktion.setName (track, "omigod we have more than one clip, what do I do? WHAT DO I DO?");
}

//NEXT SCRIPT

//Is there a way to select all clips from a highlighted track, via macros?
//Use "addObjectsToSelection" (v6.2.2). Note that this can be used in conjunction with "deselectAll"
//and "deleteSelected" to effectively create a new selection or delete a set of objects.

// Delete all clips on a Track
var track = Tracktion.getTrackFromSelectedObject();
var clips = Tracktion.getClipsFromTracks (track);

Tracktion.deselectAll();
Tracktion.addObjectsToSelection (clips);
Tracktion.deleteSelected();

// NEXT SCRIPT

//Hide automation option on a per track basis. Hide ALL automation might be nice also

// Hide automation on selected tracks
var tracks = Tracktion.getSelectedEditElements ('track');
Tracktion.hideAutomationOnTracks (tracks );

//or

// Hide all automation
var tracks = Tracktion.getEditElements ('track');
Tracktion.hideAutomationOnTracks (tracks );

//NEXT SCRIPT//

//Zoom clip to fit screen
Tracktion.zoomAroundSelection();
var track = Tracktion.getTrackFromSelectedObject();
var height = Tracktion.getTrackAreaHeight();
Tracktion.setTrackHeight (track, height);
Tracktion.scrollToShowTrack (track);

//NEXT SCRIPT

// Save selected plugins as preset
var plugins = Tracktion.getSelectedEditElements ('plugin');
Tracktion.saveObjectsAsPreset (plugins);

//NEXT SCRIPT
//Insert marker on the fly and leave the marker selected. Note the selection section.
var clip = Tracktion.insertClip ('barsBeatsMarker');
Tracktion.deselectAll();
Tracktion.addObjectsToSelection (clip);
//There may be better ways. The second line is to avoid having more than one thing selected.

// NEXT SCRIPT
//Select multiple clips and rename them 'gt'
var clips = Tracktion.getSelectedEditElements ('clip');
for (var i = 0; i < clips.length; ++i)
Tracktion.setName (clips, 'gt');

//NEW SCRIPT

//You can set the colour with
var clip = Tracktion.getSelectedEditElements ('clip');
clip[0].setProperty ('colour','ff4cff88');

//You could jump to a marker by making use of something like :

var markerPosition = clip.getProperty ('start');
Tracktion.setPosition ('cursor', markerPosition);

//You would have to iterate through all the clips in the edit using a for loop and
//testing for type "marker" and the marker "name" property. Use
var clips = Tracktion.getEditElements ('clip');
//to return all clips in the edit.

//NEXT SCRIPT
//A couple of macros that some of you may find useful as they add some more functionality to the track tagging system.
//The first macro allows you to select, solo or mute tagged tracks and the second macro lets you select the volume plugins
//on tagged tracks so you can easily adjust group fader levels.

//Selection macro:

var viewState = Tracktion.getViewState();
var tagString = viewState.getProperty ('enabledTrackTags');
tagString = "" + tagString;
var enabledTags = tagString.split("|");
var numEnabledTags = enabledTags.length;
var tracks = Tracktion.getEditElements ('track');
var trackSelected = false;


Tracktion.selectItem ('none');

var numTracks = tracks.length;
for (var i = 0; i < numTracks; ++i)
{
trackSelected = false;
tagString = tracks.getProperty('tags');
if(tagString != "")
{
tagString = "" + tagString;
trackTags = tagString.split("|");
var numTrackTags = trackTags.length;
for (var j = 0; j < numTrackTags; ++j)
{
for (var k = 0; k < numEnabledTags; ++k)
{
if(trackTags[j] == enabledTags[k])
{
Tracktion.addObjectsToSelection (tracks);
trackSelected = true;
break;
}
}
if(trackSelected == true)
break;
}

}
}

//Tracktion.soloSelectedTracks();
//Tracktion.muteSelectedTracks();

//Delete the // characters on one of the last two lines to enable soloing or muting of tagged tracks.

//Volume plugin macro:

var viewState = Tracktion.getViewState();
var tagString = viewState.getProperty ('enabledTrackTags');
tagString = "" + tagString;
var enabledTags = tagString.split("|");
var numEnabledTags = enabledTags.length;
var tracks = Tracktion.getEditElements ('track');
var selectedTracks = [];
var m = 0;
var trackSelected = false;


Tracktion.selectItem ('none');

var numTracks = tracks.length;
for (var i = 0; i < numTracks; ++i)
{
trackSelected = false;
tagString = tracks.getProperty('tags');
if(tagString != "")
{
tagString = "" + tagString;
trackTags = tagString.split("|");
var numTrackTags = trackTags.length;
for (var j = 0; j < numTrackTags; ++j)
{
for (var k = 0; k < numEnabledTags; ++k)
{
if(trackTags[j] == enabledTags[k])
{
selectedTracks[m] = tracks;
m = m + 1;
trackSelected = true;
break;
}
}
if(trackSelected == true)
break;
}
}
}

var plugins = Tracktion.getEditElements ('plugin');
var numPlugins = plugins.length - 1;
var pluginTrack;
var trackID;
var plugin;
var volPlugins = [];
m = 0;


for (var i = 0; i < numPlugins; ++i)
{
plugin = plugins;
if(plugin.getProperty ('type') == 'volume')
{
Tracktion.addObjectsToSelection (plugin);
var pluginTrack = Tracktion.getTrackFromSelectedObject();
trackID = pluginTrack.getProperty('mediaId');
Tracktion.selectItem ('none');
numTracks = selectedTracks.length;
for (var j = 0; j < numTracks; ++j)
{
if(selectedTracks[j].getProperty('mediaId') == trackID)
volPlugins[m] = plugin;
m = m + 1;
}
}
}

var numPlugins = volPlugins.length;
for (var i = 0; i < numPlugins; ++i)
Tracktion.addObjectsToSelection (volPlugins);
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post

Couldn't TSC provide some sort of place (a Wiki?) for user contributed macros?

(We're still kinda underdocumented on Macros arent we? Maybe more docs/examples could be part of it)
my other modular synth is a bugbrand

Post

whyterabbyt wrote:Couldn't TSC provide some sort of place (a Wiki?) for user contributed macros?

(We're still kinda underdocumented on Macros arent we? Maybe more docs/examples could be part of it)
That would be nice....

Until then, here is where I will be posting updates on new things I find...

http://www.kvraudio.com/forum/viewtopic ... 2&t=500416
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post

Hey I just wanted to share my solutions to needing some select marked region as a workaround, I have only finished a single track version but it works quite well.

The code goes under select marked region
here or on my github for the latest :)

Code: Select all

function selMarkedRegion() {
     /**
        Name:Marked Region Clip Select
        Description:Selects a clip that starts in the marked region. If you have selected all the clips in the track
            The selected track will be from the first track because of Tracktion logic.
        Author:Andrew Cheung
        Version:V4
        Changelog:
        +fixed bug where selectItem jumps to another track when there is only 1 clip in the track.
        +changed workaround to proper logic using getClipsFromTracks instead of getSelectedEditElements.
        +fixed can't deal with the last clip
    **/
    //Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.//selects all clips in between the in/out markers
    //affects the in/out markers
    //
    ////saves state for markers and cursors
    var curPos = Tracktion.getPosition ('cursor');
    var markInPos = Tracktion.getPosition ('markIn');
    var markOutPos = Tracktion.getPosition ('markOut');
    var curClips = Tracktion.getSelectedEditElements ('clip');

    //insert code here
    //Tracktion.selectItem ('none');//do not select all after selecting none as that will lead to a loss of focus
    var markedClips;// = Tracktion.getSelectedEditElements ('clip');
    var trackObject = Tracktion.getTrackFromSelectedObject();
    var trackClips = Tracktion.getClipsFromTracks (trackObject);
    var trackClipCount = trackClips.length;
    var firstClip;
    var lastClip;

    var clipMarkInPos;
    var clipMarkOutPos; 
    var temp;

    for (i = 0; i < trackClipCount; i++) {// for each clip
        Tracktion.selectItem ('none');
        Tracktion.addObjectsToSelection (trackClips[i]);//grab positions to check if it is in marked area
    //    temp = Tracktion.getSelectedEditElements ('clip');//holds the current indexed object
        Tracktion.markAroundSelected();
        clipMarkInPos = Tracktion.getPosition ('markIn');
        clipMarkOutPos = Tracktion.getPosition ('markOut');
        if (markInPos <= clipMarkInPos && clipMarkInPos < markOutPos){//
            Tracktion.addObjectsToSelection (markedClips);
            markedClips = Tracktion.getSelectedEditElements ('clip');//puts the clip into the marked clip list
            //break;
        }
    }

    Tracktion.selectItem ('none');
    Tracktion.addObjectsToSelection (markedClips);
    //code end

    //reset changes to markers and cursors
    //Tracktion.addObjectsToSelection (curClips);//if you select some stuff and haven't deleted any clips use this to default
    Tracktion.setPosition ('cursor', curPos);
    Tracktion.setPosition ('markIn', markInPos);
    Tracktion.setPosition ('markOut', markOutPos);
}
for more check out my ripple delete macro!
viewtopic.php?f=22&t=486975&p=7015908#p7015908

Post

Very cool!

We are trying to put together a running thread here.....

viewtopic.php?f=22&t=500416
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post Reply

Return to “Tracktion”