loop selected region

tubular2000
KVRer
25 posts since 1 Oct, 2018

Post Sat Oct 12, 2019 5:59 pm

hi, is there a way to trigger the "loop selected region" from a script? i can't find it in the api.
i would also be able to move the loop start and length with rotary encoders.

any ideas?

thanks

DIZZNESS
KVRer
20 posts since 24 Jul, 2020

Post Wed Aug 05, 2020 8:59 am

Hi,

did you found and answer? I'm lloking for the same things!

User avatar
moss
KVRAF
2319 posts since 13 May, 2004

Post Thu Aug 06, 2020 1:13 am

All items in the shortcut list are "Actions". Get an action with

Code: Select all

Action getAction (String  id)
from Application and call invoke().

To find the ID you can list all actions with getActions().

Here is my test script for actions:

Code: Select all

loadAPI(7);

host.defineController("Moss", "Dump Actions", "1.0", "A2A82633-EC3A-48AD-A5B2-51EBD38F1CB1", "Jürgen Moßgraber");
host.defineMidiPorts(0, 0);

var application = null;
var actions = null;
var formattedActions = null;
var actionList = null;

function init ()
{
    application = host.createApplication ();
    actions = application.getActions ();
    println (actions.length + " actions available.");
    formatActions ();

    var preferences = host.getPreferences ();

    preferences.getSignalSetting (" ", "Dump", "Dump first 200 to console").addSignalObserver (function () {
        for (var i = 0; i < 200; i++)
            println (i + ":" + actions[i].getId () + ":" + actions[i].getCategory ().getName () + ":" + actions[i].getName ());
    });
    preferences.getSignalSetting ("  ", "Dump", "Dump rest to console").addSignalObserver (function () {
        for (var i = 200; i < actions.length; i++)
            println (i + ":" + actions[i].getId () + ":" + actions[i].getCategory ().getName () + ":" + actions[i].getName ());
    });

    actionList = preferences.getEnumSetting ("Actions", "Execute", formattedActions, formattedActions[0]);
    actionList.markInterested ();

    preferences.getSignalSetting ("   ", "Execute", "Execute").addSignalObserver (function () {
        var action = actionList.get ();
        for (var i = 0; i < formattedActions.length; i++)
        {
            if (action == formattedActions[i])
            {
                println ("Executing: " + actions[i].getName ());
                actions[i].invoke ();
            }
        }
    });
}

function formatActions ()
{
    formattedActions = [];
    for (var i = 0; i < actions.length; i++)
        formattedActions[i] = actions[i].getName ();
}

function callAction (actionID)
{
    var action = application.getAction (actionID);
    if (action == null)
        println("Action not found.");
    else
    {
        println("Executing: " + action.getName ());
        action.invoke ();
    }
}

function exit()
{
   println ("Exit");
}

User avatar
Kirkwood West
KVRist
39 posts since 12 Apr, 2020

Post Sun Aug 09, 2020 2:13 pm

That is awesome Moss! Thanks for the handy script too!
----------------------------------------------------------------------
http://instagram.com/kirkwoodwest/
http://soundcloud.com/kirkwoodwest

Return to “Controller Scripting”