[Macro] Tracktion Feature! Ripple Editting!

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

Post

Have you ever needed to ripple edit things like a podcast, kinda like when you edit videos!?
Now you can with the use of these two macros! Made by yours truly!

I have more macros in my github so if you are into that go for it!
https://github.com/OSBooter/Tracktion-WF-Macros
<3

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);
}

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);
}
Last edited by OSBooter on Tue Feb 27, 2018 8:36 pm, edited 1 time in total.

Post

These are fantastic and much more elegant than something similar I came up with. Where are you getting info on methods like ‘markaroundselected’ and such? (A decent list of methods is sorely needed....)
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post

Also, thanks for the link to your github. ‘Select clip in selected region’ is something I’ve been really needing!!
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post

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".

Post

Thanks for these nice macros by the way

Post

AGreen wrote: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".

Thanks for the tip!

:tu:
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post

OSBooter, AGreen - I posted the macros and info from this tab in the macro compilation thread here: viewtopic.php?f=22&t=500416&p=7015928#p7015928
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post

I'm glad to be of help :)

Post Reply

Return to “Tracktion”