Javascript Macro Action Requests

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

Post

phledo wrote:Being able to use QWERTY key strokes would be nice.
That's a nice idea but I'm afraid tabbing to get to text fields wouldn't be robust enough. If we move UI elements around the tabs will go to the wrong components and so the scripts would all be wrong.
It's probably better to request specific bits of API you would like and then we can implement them.

For renaming tracks you can do this like so:

Code: Select all

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.

Post

busywait wrote:Event handlers for selections and marker clips on the Marker Track.

I want to register a macro to be run when the selected region is entered for the first time.

Like, I want to be able to turn on loop mode when the play head enters the selected region (that is, when and if the cursor hits the 'in' marker)

I don't know if registering handlers for these events would be best done in code or with a bit more UI. Certainly there is room in the Marker Clip properties panel for a macro to be referenced.

Maybe code would look like
selection.onEnter( toggleTransport('loop') );
or
Markers( 'Marker 1' ).onEnter( selectCurrentMarkerAndLoop() );
That's a very cool idea. It's not something the current engine would support though as all these scripts are parsed and run when the action is called (i.e. a key press or "Run Script" button).
It might be possible to add dispatchers to events like this which would yield a slightly different paradigm: select marker clip -> add action -> on enter -> run script X

I do like the idea of more Javascript-esque event handlers though. Perhaps it's something we'll look into in the future.

Post

dRowAudio wrote:
Kang wrote:Create a track named X

Rewind X amount

Load plugin with preset X

Any of these possible?
Hi Kang, I've just added some action to do these now. Here's what the scripts would look like:

Code: Select all

// 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);
Those, like the examples in the video, all seem to imply that X is fixed; hardcoded into the script. Are we likely to get user-interaction capabilities that let us define them at runtime eg

Code: Select all

var track = Tracktion.insertTrack ('audio');
var trackName = prompt.String("Track Name?);
Tracktion.setName (track, trackName);

var currentPos = Tracktion.getPosition ('transport');
var rewindTime = prompt.Float("Rewind By (secs)?);
Tracktion.setPosition ('transport', currentPos - rewindTime);
my other modular synth is a bugbrand

Post

dRowAudio wrote:
Kang wrote:Create a track named X

Rewind X amount

Load plugin with preset X

Any of these possible?
Hi Kang, I've just added some action to do these now. Here's what the scripts would look like:

Code: Select all

// 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);
Unfortunately, I couldn't get either of the two macros you listed to work. It's telling me that setPosition and setName are unknown functions.

Thank you very much for looking into this though.
dRowAudio wrote:When you say "Load plugin with preset X" do you mean a named preset from the factory presets or a custom preset you have saved to the Tracktion preset library?
I was more thinking a preset that I made if possible, but either would be cool. I'm dreaming of setting up complete track recording chains with a keystroke.

Post

Or did you possibly mean that you added these in for a future release? If so, AMAZING!

Post

busywait wrote:I would like to be able to bring a new named Edit in to focus.

Currently
Traction.showEditScreen();
exists, but it will only show the last used edit screen. I'd like to be able to referenced a named edit screen

Tracktion.showEditScreen( 'Song 2' );

Or at least add
Tracktion.nextEditScreen();
I thought about adding an action to bring a named Edit to the front but that currently requires the name to be hard coded in the script which means it will likely only be valid for a short time.

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.

Code: Select all

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

Post

Kang wrote:Or did you possibly mean that you added these in for a future release? If so, AMAZING!
Yes sorry, these will be in Tracktion 6.2.1 or later.

Automating track set-ups is exactly the kind of thing we would like this to be able to do so let us know what you need.

Post

whyterabbyt wrote:Those, like the examples in the video, all seem to imply that X is fixed; hardcoded into the script. Are we likely to get user-interaction capabilities that let us define them at runtime eg

Code: Select all

var track = Tracktion.insertTrack ('audio');
var trackName = prompt.String("Track Name?);
Tracktion.setName (track, trackName);

var currentPos = Tracktion.getPosition ('transport');
var rewindTime = prompt.Float("Rewind By (secs)?);
Tracktion.setPosition ('transport', currentPos - rewindTime);
This isn't currently possible but is certainly something I'll be looking into once the feature is out of beta.

Post

dRowAudio wrote: Automating track set-ups is exactly the kind of thing we would like this to be able to do so let us know what you need.
Great!

The plugin preset thing is a big one for this. I think user made presets would be the best option.

Would there also be a way to scroll through active automation lines per track with macros?

Post

Kang wrote: Great!

The plugin preset thing is a big one for this. I think user made presets would be the best option.
Just added a couple of ways to do this. Either by applying a preset to a plugin or adding a preset directly:

Code: Select all

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

Code: Select all

// Insert Named Preset
var track = Tracktion.getTrackFromSelectedObject();
var preset = Tracktion.getPresetFromLibrary ("Massive All Souls");
Tracktion.insertPluginPreset (track, preset);
Kang wrote:Would there also be a way to scroll through active automation lines per track with macros
What exactly would you like here? Something that enables you to choose which automation parameter is shown on a track or a transport function to move over the different automation points (in time)?

Post

The former. So that you could scroll through which active automation line shows on the track.

I suppose it could just as easily be a regular keyboard shortcut, but it would be great for mixing.

Post

Would it be possible to control armed inputs?

When someone says, "keep that, but try another" you could have a macro that creates a new track , etc, etc, and moves the already armed input to it. Even if not, that other stuff is going to come in major handy.

Also, what about named markers on the fly?

Imagine... CTRL+SHIFT+C creates a marker named "chorus", CTRL+SHIFT+V could be "verse", and CTRL+SHIFT+B "bridge". Obviously you can make it whatever you want, I'm just pointing out how cool it would be.

Post

Moving by time is cool, but so would be moving by beats. I know it is not typical javascripting, but it is common in scripts to be able to "wait" or "sleep" for a given amount of time. That could also be done in both time and beats.

Post

Rock wrote:Moving by time is cool, but so would be moving by beats. I know it is not typical javascripting, but it is common in scripts to be able to "wait" or "sleep" for a given amount of time. That could also be done in both time and beats.
one way of doing it would just need a conversion function, eg 'convertBeatsToSecs' which works out how many seconds (or samples) long a given measure is at a specific tempo.

Code: Select all

var currentPos = Tracktion.getPosition ('transport');
var rewindTime = convertBeatsToSecs(getCurrentTempo, 1, "bar")
Tracktion.setPosition ('transport', currentPos - rewindTime);
The problem is tempo changes. If you move backwards 1 bar, but there's a tempo change 'inside' that time range, what happens, how should it calculate how long that bar actually is?
my other modular synth is a bugbrand

Post

Kang wrote:Also, what about named markers on the fly?
Just added this. You can now add the clip types: 'barsBeatsMarker' & 'absoluteMarker'.
insertClip also returns an object so you can rename it or move it around etc.

Code: Select all

// Insert Bars/Beats Marker Clip
var clip = Tracktion.insertClip ('barsBeatsMarker');
Tracktion.setName (clip, "Hello world!");

Post Reply

Return to “Tracktion”