Compilation of Working Macros

Discussion about: tracktion.com
User avatar
gesslr
KVRist
487 posts since 8 Apr, 2014 from USA

Post Wed Feb 21, 2018 7:24 am

Hi.

I pulled working macros from several threads in an attempt to create a study reference and "documentation by inference". I'm going to post them below and try to keep the list updated as macros get posted. (What is really needed is some documentation of existing methods and such. If anyone knows of such a thing, please post some info.)*

04/09/18 EDIT: Great news! As of Waveform 9.1.1 the ability to list the API Reference has been added! See this video by Bill Edstrom for details on how to do this: https://youtu.be/Gbg3YUrXO_s?t=3m58s


Feel free to post working macros here (or flag anything in the list that doesn't work) but I'd like to try to keep this as a list of working macros, not a discussion of macros. To discuss macros, ask for help, or make requests, there are a couple of excellent threads in the forum:

This is the main thread from which most of these were pulled and where a lot of discussion occurs
viewtopic.php?f=22&t=441475&hilit=macro

This is a thread with some excellent macros from AGreen
viewtopic.php?f=22&t=486975&p=7015908#p7015908

This is a thread from TSC talking about the addition of Macros and some examples
http://www.kvraudio.com/forum/viewtopic ... 2&t=441200

* - From user AGreen:
"You can get info on some functionality by looking at existing keyboard shortcuts in the macro editor. You can also discover properties by opening the Waveform edit file in something like Wordpad. You'll see there are various assignments of properties and types, for example within the "track" section you will see properties like "filter" and "name"."
Hope folks find this helpful.

OK. Here is the list:

Code: Select all

//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

Code: Select all

//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

Code: Select all

//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

Code: Select all

//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

Code: Select all

//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

Code: Select all

//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

Code: Select all

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

Code: Select all

//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[i];
   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[i];
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

Code: Select all

//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

Code: Select all

//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//

Code: Select all

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

Code: Select all

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

Code: Select all

//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

Code: Select all

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

//NEW SCRIPT

Code: Select all

//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

Code: Select all

//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[i].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[i]);
                    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[i].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[i];
                    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[i];
    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[i]);

//NEXT SCRIPT

Code: Select all

//Select/solo/mute tracks using text boxes:
var plugins = Tracktion.getSelectedEditElements ('plugin');
var plugin = plugins[0];
var title = "";
var tracks = [];
var j = 0;

title = plugins[0].getProperty ('title');

Tracktion.selectItem ('none');

plugins = Tracktion.getEditElements ('plugin');

for (var i = 0; i < plugins.length; ++i)
{
   plugin = plugins[i];

   if (plugin.getProperty ('type') == 'text'
         && plugin.getProperty ('title') == title)
      {
           Tracktion.addObjectsToSelection (plugin);
           tracks[j] = Tracktion.getTrackFromSelectedObject();
           Tracktion.selectItem ('none');
           j = j + 1;
      }
}


var numTracks = tracks.length;
for (var i = 0; i < numTracks; ++i)
   Tracktion.addObjectsToSelection (tracks[i]);

//Tracktion.soloSelectedTracks(); 
//Tracktion.muteSelectedTracks();   
//Delete the // characters on one of the last two lines to enable soloing or muting of tagged tracks.
//To use, put text boxes on tracks with names like"Guitar" etc. Select text 
//box then run macro. It's an alternative to tags and doesn't require sidebar 
//open so works in the mixer on a seperate screen or tab. Create an empty first 
//track and put all text boxes on this track so you can select by going to first track.
//NEXT SCRIPT

Code: Select all

//Show soloed tracks only:
var viewState = Tracktion.getViewState();
viewState.setProperty ('enabledTrackTags', '');
var tracks = Tracktion.getEditElements ('track');
var numTracks = tracks.length;
var unSoloedTracks = [];
var soloedTracks = [];
var solo = false;
var j = 0;

Tracktion.selectItem ('none');

for (var i = 0; i < numTracks; ++i)
{
    if(Tracktion.isSolo (tracks[i]) == false)
    {
        unSoloedTracks[j] = tracks[i];
        j = j + 1;
    }
    else
    {
        tracks[i].setProperty ('hidden', '0');
        solo = true;
    }

}

if(solo == true)
{
    numTracks = unSoloedTracks.length;
    for (var i = 0; i < numTracks; ++i)
        unSoloedTracks[i].setProperty ('hidden', '1');
   
    if(viewState.getProperty('showTaggedTracks') == 1)
    {
        viewState.setProperty ('showTaggedTracks', '0');
        viewState.setProperty ('showTaggedTracks', '1');
    }
    else
    {
        viewState.setProperty ('showTaggedTracks', '1');
        viewState.setProperty ('showTaggedTracks', '0');
    }
    
}
//NEXT SCRIPT

Code: Select all

//Show selected tracks only:
var tracks = Tracktion.getEditElements ('track');
var selectedTracks = Tracktion.getSelectedEditElements ('track');
var numTracks = tracks.length;
var numSelected = selectedTracks.length;
viewState.setProperty ('enabledTrackTags', '');

for (var i = 0; i < numTracks; ++i)
    tracks[i].setProperty ('hidden', '1');

for (var i = 0; i < numSelected; ++i)
    selectedTracks[i].setProperty ('hidden', '0');

if(viewState.getProperty('showTaggedTracks') == 1)
    {
        viewState.setProperty ('showTaggedTracks', '0');
        viewState.setProperty ('showTaggedTracks', '1');
    }
    else
    {
        viewState.setProperty ('showTaggedTracks', '1');
        viewState.setProperty ('showTaggedTracks', '0');
    }

//NEXT SCRIPT

Code: Select all

//Show hidden tracks:
var tracks = Tracktion.getEditElements ('track');
var numTracks = tracks.length;

for (var i = 0; i < numTracks; ++i)
    tracks[i].setProperty ('hidden', '0');

 if(viewState.getProperty('showTaggedTracks') == 1)
    {
        viewState.setProperty ('showTaggedTracks', '0');
        viewState.setProperty ('showTaggedTracks', '1');
    }
    else
    {
        viewState.setProperty ('showTaggedTracks', '1');
        viewState.setProperty ('showTaggedTracks', '0');
    }
//NEXT SCRIPT

Code: Select all

//Reset all tracks solo state:
var tracks = Tracktion.getEditElements ('track');
Tracktion.setSolo (tracks, false);
Tracktion.setSoloIsolate (tracks, false);
//NEXT SCRIPT

Code: Select all

//Reset all tracks mute state:
var tracks = Tracktion.getEditElements ('track');
Tracktion.setMute (tracks, false);
//NEXT SCRIPT - From this thread: viewtopic.php?f=22&t=500614&p=7019198#p7019198

//Multi track ripple edit macro

Code: Select all

/**
    Name:Multi Track Ripple Delete and Go to Next
    Description:The selected clip or clips in the single track become the extent of the
        ripple delete. The first and the last slip tell how much is deleted and shifted,
        all tracks are affected!
    Author:Andrew Cheung
    Version:V1
    Changelog:
    +includes helper functions like get next clip
**/
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
copyOneClip (curClips);
var allTracks = getAllTracks();
var rightClip = getRightClip();
//Tracktion.markAroundSelected();//get current selected

//chop out selection
Tracktion.markAroundSelected();//get current selected
//get a clip with in the selected region
var selMarkInPos = Tracktion.getPosition ('markIn');
var selMarkOutPos = Tracktion.getPosition ('markOut');
//check if all tracks have clips in the span
//which if not will paste something there temporarily


//select all clips
Tracktion.addObjectsToSelection (Tracktion.getEditElements ('clip'));

    //split at clip some stuff
    Tracktion.jumpToMarkIn();
    Tracktion.splitClips();
    Tracktion.jumpToMarkOut();
    Tracktion.splitClips();

    for (i = 0; i < allTracks.length; i++){//goes through all tracks to make sure ripple delete does it to all
        Tracktion.selectItem ('none');
        Tracktion.addObjectsToSelection (allTracks[i]);
        Tracktion.jumpToMarkIn();
        Tracktion.paste();//adds a dummy clip to every track to allow ripple delete to work
    }

    Tracktion.addObjectsToSelection (Tracktion.getEditElements ('clip'));

    Tracktion.deleteMarkedRegionOfSelectedClipsAndClose();
    Tracktion.selectItem ('none');
    Tracktion.addObjectsToSelection (rightClip);


//    Tracktion.addObjectsToSelection (allTracks[4]);
//end

Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);

//Functions
function copyOneClip (clips) {
    /**
        Name:Copy One Selected
        Description:Given clips, Copy one of them
        Author:Andrew
        Version:V1
    **/
    //Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.
    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');
    Tracktion.addObjectsToSelection (clips[0]);
    Tracktion.copy();
    //code end
    Tracktion.selectItem ('none');
    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);

}

function getAllTracks(){
    /**
        Name:Get All Tracks
        Description:gets an array of tracks from the edit
        Author:Andrew
        Version:V1
    **/
    //Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.
    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');
    Tracktion.addObjectsToSelection (Tracktion.getEditElements ('track'));
    var allTracks;
    allTracks = Tracktion.getSelectedEditElements ('track');    
    //code end
    Tracktion.selectItem ('none');
    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);
    return allTracks;
}

function getRightClip (){
    /**
        Name:Get Clip to the Right
        Description:Gives you what everclip is to the right of the selection
        Author:Andrew Cheung
        Version:V1
    **/
    //Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.
    var curPos = Tracktion.getPosition ('cursor');
    var markInPos = Tracktion.getPosition ('markIn');
    var markOutPos = Tracktion.getPosition ('markOut');
    var curClips = Tracktion.getSelectedEditElements ('clip');
    var rightClip;
    //insert code here
    Tracktion.selectItem ('right');
    rightClip = Tracktion.getSelectedEditElements ('clip');
    //code end
    Tracktion.selectItem ('none');
    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);
    return rightClip;
}

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);
}
//NEXT SCRIPT
// Single track ripple edit

Code: Select all

/**
    Name:Single Track Ripple Delete and Go to Next
    Description:The selected clip or clips in the single track become the extent of the
        ripple delete. The first and the last clip tell how much is deleted and shifted. 
        Then select the next clip. 
    Author:Andrew Cheung
    Version:V1
    Changelog:
    *updated marked clip code to v4
    -suffers from error if two clips from different tracks are selected.
        This only works with one track, and it will ripple the bottom most track if more tracks are selected.
**/
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
var rightClip = getRightClip();
Tracktion.markAroundSelected();//get current selected

//chop out selection
Tracktion.selectItem ('all');
Tracktion.jumpToMarkIn();
Tracktion.splitClips();
Tracktion.jumpToMarkOut();
Tracktion.splitClips();
//Tracktion.selectItem ('none');

//select only marked region
selMarkedRegion();
Tracktion.deleteMarkedRegionOfSelectedClipsAndClose();
Tracktion.addObjectsToSelection (rightClip);
//end

//var markInPos = Tracktion.getPosition ('markIn');
//var markOutPos = Tracktion.getPosition ('markOut');
//var selmarkIn = Tracktion.getPosition ('markIn');
//var selmarkOut = Tracktion.getPosition ('markOut');
//var selmarkFirstClip = Tracktion.getPosition ('markIn');
//var selmarkLastClip = Tracktion.getPosition ('markOut');
//Tracktion.selectItem ('right');// selects only one item
Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);

//Functions

function getRightClip (){
    /**
        Name:Get Clip to the Right
        Description:Gives you what everclip is to the right of the selection
        Author:Andrew Cheung
        Version:V1
    **/
    //Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.
    var curPos = Tracktion.getPosition ('cursor');
    var markInPos = Tracktion.getPosition ('markIn');
    var markOutPos = Tracktion.getPosition ('markOut');
    var curClips = Tracktion.getSelectedEditElements ('clip');
    var rightClip;
    //insert code here
    Tracktion.selectItem ('right');
    rightClip = Tracktion.getSelectedEditElements ('clip');
    //code end
    Tracktion.selectItem ('none');
    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);
    return rightClip;
}


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);
}
//OSBooter (author of above ripple edit macros) has more macros in his github "so if you are into that go for it!"
// https://github.com/OSBooter/Tracktion-WF-Macros
Last edited by gesslr on Mon Apr 09, 2018 9:45 am, edited 4 times in total.
------------
MacPro 5,1 | 64gb | OSX 10.13.6 | Studio One 4| Waveform 9 | Logic Pro X | BWS 2.3.5 | CubasePro 9.5 |

http://www.soundwaremedia.com
http://www.facebook.com/geo.napier3

User avatar
whyterabbyt
Beware the Quoth
26108 posts since 4 Sep, 2001 from R'lyeh Oceanic Amusement Park and Funfair

Re: Compilation of Working Macros

Post Wed Feb 21, 2018 8:09 am

It would be preferable if you put them in code blocks, as per AGreen's posts.

unformatted:

//Reset all tracks mute state:
var tracks = Tracktion.getEditElements ('track');
Tracktion.setMute (tracks, false);

versus code blocks

Code: Select all

//Reset all tracks mute state:
var tracks = Tracktion.getEditElements ('track');
Tracktion.setMute (tracks, false);
"The bearer of this signature is a genuine and authorised pope."

User avatar
gesslr
KVRist
487 posts since 8 Apr, 2014 from USA

Re: Compilation of Working Macros

Post Wed Feb 21, 2018 8:46 am

OK. I'll do that in a bit....
------------
MacPro 5,1 | 64gb | OSX 10.13.6 | Studio One 4| Waveform 9 | Logic Pro X | BWS 2.3.5 | CubasePro 9.5 |

http://www.soundwaremedia.com
http://www.facebook.com/geo.napier3

AGreen
KVRist
97 posts since 2 Feb, 2015

Re: Compilation of Working Macros

Post Fri Feb 23, 2018 5:27 am

Here are a couple of macros to expand and collapse folder tracks

Expand folders:

Code: Select all

var folders = Tracktion.getEditElements ('track');
for (var i = 0; i < folders.length; ++i)
    folders[i].setProperty ('expanded', '1');
Collapse folders:

Code: Select all

var folders = Tracktion.getEditElements ('track');
for (var i = 0; i < folders.length; ++i)
    folders[i].setProperty ('expanded', '0');

User avatar
gesslr
KVRist
487 posts since 8 Apr, 2014 from USA

Re: Compilation of Working Macros

Post Fri Feb 23, 2018 2:40 pm

whyterabbyt wrote:It would be preferable if you put them in code blocks, as per AGreen's posts.

unformatted:

//Reset all tracks mute state:
var tracks = Tracktion.getEditElements ('track');
Tracktion.setMute (tracks, false);

versus code blocks

Code: Select all

//Reset all tracks mute state:
var tracks = Tracktion.getEditElements ('track');
Tracktion.setMute (tracks, false);

Done!
------------
MacPro 5,1 | 64gb | OSX 10.13.6 | Studio One 4| Waveform 9 | Logic Pro X | BWS 2.3.5 | CubasePro 9.5 |

http://www.soundwaremedia.com
http://www.facebook.com/geo.napier3

OSBooter
KVRer
10 posts since 7 Dec, 2014

Re: Compilation of Working Macros

Post Sun Feb 25, 2018 1:04 am

All my resources can be found in my git, https://github.com/OSBooter/Tracktion-WF-Macros
and for function snippets https://github.com/OSBooter/Tracktion-W ... /functions
There's a very useful strategy for a function I'd like to mention by grabbing the current selection, the positions of cursor and in/out markers, you can move them and then place them back when you are done, for example in my pull next clip to current end of clip code.

Code: Select all

/**
    Name:Pull Next Clip to Tail
    Description:Pulls the next clip to the end of the selected clip,
    Author:Andrew Cheung
    Version:V2
    Changelog:
    -it can't handle two selected clips from different tracks
**/
//capture default
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
//code
Tracktion.markAroundSelected();
Tracktion.jumpToMarkOut();
Tracktion.selectItem ('right');
Tracktion.moveStartOfSelectedClipsToCursor();
//code end
//reset to default
Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);

Feel free to use my template code (also found in my github :))

Code: Select all


/**
    Name:Name
    Description:Biblos geneseōs Iēsou Christou huiou Daueid huiou Abraam.
    Author:Jane Doe
    Version:V1
**/
//Tip: Avoid select none without keeping a focusable object or there might be a freeze state.
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
//insert code here


//code end
Tracktion.selectItem ('none');
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);

User avatar
gesslr
KVRist
487 posts since 8 Apr, 2014 from USA

Re: Compilation of Working Macros

Post Sun Feb 25, 2018 9:08 am

OSBooter wrote:All my resources can be found in my git, https://github.com/OSBooter/Tracktion-WF-Macros
and for function snippets https://github.com/OSBooter/Tracktion-W ... /functions

>SNIP<
Fantastic. Thanks!
------------
MacPro 5,1 | 64gb | OSX 10.13.6 | Studio One 4| Waveform 9 | Logic Pro X | BWS 2.3.5 | CubasePro 9.5 |

http://www.soundwaremedia.com
http://www.facebook.com/geo.napier3

gigazaga
KVRist
342 posts since 21 Feb, 2009

Re: Compilation of Working Macros

Post Sun Feb 25, 2018 9:24 am

Excellent thread!

User avatar
operandx
KVRist
296 posts since 30 Apr, 2003 from West Dorset, UK

Re: Compilation of Working Macros

Post Sun Feb 25, 2018 9:42 am

Can a Mod make this thread sticky? So much useful stuff here.
'He craved immortality so much, he was prepared to die for it.'

User avatar
gesslr
KVRist
487 posts since 8 Apr, 2014 from USA

Re: Compilation of Working Macros

Post Mon Feb 26, 2018 3:38 am

Thanks for making this a sticky, Dave!

George N. (aka gesslr)

:tu:
------------
MacPro 5,1 | 64gb | OSX 10.13.6 | Studio One 4| Waveform 9 | Logic Pro X | BWS 2.3.5 | CubasePro 9.5 |

http://www.soundwaremedia.com
http://www.facebook.com/geo.napier3

iwaiwa
KVRer
5 posts since 17 Dec, 2006

Re: Compilation of Working Macros

Post Tue Mar 27, 2018 2:03 pm

I moved my Script Request from here to Javascript Macro Action Requests

thanks

Return to “Tracktion”