Hey, not sure if am missing something in the macro/scripting functions, but I wanted to have the "L" loop toggle on a clip trigger with a hotkey, and I could not find it as an available macro function anywhere, so I decided to write a little script for it. I've tested it on some of my midi clips and it seems to work fine. If I've missed something (script-wise) or this function actually is available as a macro, feel free to let me know. Otherwise I thought this might be useful to some of you
Code: Select all
var clips = Tracktion.getSelectedEditElements ('clip');
// math.round both rounds numbers and ensures values are returned as float. It seems they sometimes are not otherwise
var lsb = Math.round(clips[0].getProperty('loopStartBeats'));
var llb = Math.round(clips[0].getProperty('loopLengthBeats'));
// current length
var l = Math.round(clips[0].getProperty('length'));
// offset changes loopstarbeats
var o = Math.round(clips[0].getProperty('offset'));
//llb > 0 means we have a loop. So we disable looping. Otherwise we enable it.
if(llb > 0)
{
// unloop
clips[0].setProperty('loopLengthBeats', 0);
// reset length
clips[0].setProperty('length', llb * 0.5);
l = clips[0].getProperty('length');
// start offset
clips[0].setProperty('offset', lsb * 0.5);
}
else
{
clips[0].setProperty('loopLengthBeats', l *2);
clips[0].setProperty('length', l * 2);
// start offset to 0
clips[0].setProperty('offset', 0);
// loop offset to offset * 2
clips[0].setProperty('loopStartBeats', o * 2);
}
