A technical support community for Apple Logic Pro users.

 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

TIP: Scripter Keyswitches

Sun Jun 07, 2020 5:03 pm

Articulation Keyswitching with Scripter

This post and thread will discuss some simple methods for sending articulation keyswitches using Scripter. The examples are being kept extremely simple in order to show the general concepts. More elaborate scenarios can also be handled. I will provide a few different approaches in different posts of this thread so you can explore them all and adapt to your own needs whatever works best. These are all small, simple and efficient scripts...any of which can overcome LogicPro's limitation of only 3 keyswitchs per articulationID in the articulationSet.

Sending Keyswitch per Aritculation ID.

Mainly the script needs to do the following in some manner:

  1. Look for articulationID in the incoming NoteOn object
  2. Based on the articulationID (if it exists), send one or more keyswitches
  3. Send the actual NoteOn

Here is a simple to understand example script:

function HandleMIDI(event) {

    if( ! (event instanceof NoteOn) ) {
        event.send();
        return;
    }

    if(event.articulationID == undefined
            || event.articulationID < 1) {
        event.send();
        return;
    }
   
    switch(event.articulationID) {
    case 1:
        Staccato(event);
        break;
    case 2:
        Legato(event);
        break;
    case 3:
        Spiccato(event);
        break;
    default:
        event.send();
    }
}

function Staccato(event) {
    sendSwitch("C-2", event);
    sendSwitch("D0", event);
    sendSwitch("D1", event);
    sendSwitch("C-1", event);
    sendSwitch("D#0", event);
    sendSwitch("D#1", event); 
   
    event.send();
}

function Spiccato(event) {
    sendSwitch("C-2", event);
    sendSwitch("D0", event);
    sendSwitch("D1", event);
    sendSwitch("C-1", event);
    sendSwitch("D#0", event);
    sendSwitch("D#2", event); 
   
    event.send();
}

function Legato(event) {
    sendSwitch("C-2", event);
    sendSwitch("D0", event);
    sendSwitch("D1", event);
    sendSwitch("C-1", event);
    sendSwitch("D#0", event);
    sendSwitch("D#3", event); 
   
    event.send();
}

var ks = new NoteOn;

function sendSwitch(ksName, ev) {
    ks.channel = ev.channel;
    ks.pitch = MIDI.noteNumber(ksName);
    ks.velocity = 100;
    ks.send();
    ks.velocity = 0;
    ks.send();
}


A couple points about the above simple example:

  1. This example only provides NoteOn keyswitches, but more elaborate logic can be developed in order to send CC's or other events as keyswitches (see another latest post in this thread for that).

  2. This example also plays keyswitches for every note, even if the previous note was the same articulationID. its not hard to avoid that, see a later example in this thread for how to do that.

  3. Note that each Keyswitch needs both a NoteOn and a NoteOff event. The easy way to send a matching NoteOff is to simply use the NoteOn object and set the velocity to zero, which in LogicPro is considered the same as a NoteOff.

  4. Also, note that for these kinds of scripts to work, the articulationSet must not have any entries in the OUTPUT section because when there are entries in the OUTPUT section, the articulationID will be stripped from the event

Any questions, comments or discussion will be welcomed here...

Please see later posts in this thread with more example scripts using different approaches and handling a few issues better then this first one which is meant as the simplest simple example.
Last edited by Dewdman42 on Sun May 02, 2021 2:45 pm, edited 7 times in total.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
GtrJazz
Posts: 103
Joined: Fri Sep 05, 2008 10:37 pm

Re: TIP: Keyswitches

Tue Jun 09, 2020 8:45 am

Is it possible to assign a key command to switch automation articulation switching via scripter?

Id like to be able to toggle between CC1 and CC11 and this articulation script via key commands on iPad
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Tue Jun 09, 2020 2:10 pm

Scripter can't respond to keyboard commands, only midi and automation. You could use Keyboard Maestro to send midi commands from key commands, which could solve the problem for you, but that involves purchasing a third party product (Keyboard Maestro).
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
GtrJazz
Posts: 103
Joined: Fri Sep 05, 2008 10:37 pm

Re: TIP: Keyswitches

Tue Jun 09, 2020 3:26 pm

Thanks for the reply. Would this work with
osculator by any chance?
 
ValliSoftware
Posts: 979
Joined: Mon May 19, 2014 10:46 am

Re: TIP: Keyswitches

Tue Jun 09, 2020 4:29 pm

GtrJazz wrote:
Id like to be able to toggle between CC1 and CC11 and this articulation script via key commands on iPad

What program are you using on the iPad?
MacBook Pro 10.8.5 2.2 GHz Intel Core 2 Duo 6GB Ram - Logic Pro X (10.2)
MacMini 10.13.6 2GHz Intel Core i7 16GB Ram - GarageBand 10.4.5 Logic Pro X (10.4.8)
iPad Mini iOS 12 - iOS GarageBand 2.0.1
Qosimo X70-A 10.13.6 Intel® Core™ i7-4700MQ Processor 32GB DDR3L 1600MHz memory, 2-500GB 7200rpm hard drives - Logic Pro X (10.4.8)
MacMini M1 11.4 Apple M1 16GB Ram 1TB SSD Logic Pro X (10.6.2) Rosetta 2 not installed
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Tue Jun 09, 2020 4:59 pm

I’m not sure about osculator but I don’t think so
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
GtrJazz
Posts: 103
Joined: Fri Sep 05, 2008 10:37 pm

Re: TIP: Keyswitches

Tue Jun 09, 2020 7:03 pm

[quote="ValliSoftware"][quote="GtrJazz"]
Id like to be able to toggle between CC1 and CC11 and this articulation script via key commands on iPad[/quote]
What program are you using on the iPad?[/quote]


I’ve got lemur and metagrid
 
ValliSoftware
Posts: 979
Joined: Mon May 19, 2014 10:46 am

Re: TIP: Keyswitches

Tue Jun 09, 2020 8:05 pm

GtrJazz wrote:
I’ve got lemur and metagrid

Did you setup Metagrid to work with Logic Pro X as in this video.
MacBook Pro 10.8.5 2.2 GHz Intel Core 2 Duo 6GB Ram - Logic Pro X (10.2)
MacMini 10.13.6 2GHz Intel Core i7 16GB Ram - GarageBand 10.4.5 Logic Pro X (10.4.8)
iPad Mini iOS 12 - iOS GarageBand 2.0.1
Qosimo X70-A 10.13.6 Intel® Core™ i7-4700MQ Processor 32GB DDR3L 1600MHz memory, 2-500GB 7200rpm hard drives - Logic Pro X (10.4.8)
MacMini M1 11.4 Apple M1 16GB Ram 1TB SSD Logic Pro X (10.6.2) Rosetta 2 not installed
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Tue Jun 09, 2020 8:37 pm

Scripter can respond to midi and automation. You can setup smart controls to control the automation. Aside from that in order to switch via keyboard you would need to use Keyboard Maestro and have that send midi into LogicPro. If you use something like MetaGrid, then same thing..it will will need to send midi in response to you pressing an icon on the iPad. Either way, the midi has to be routed into the channel you are using to host Scripter...then you would be able to control Scripter that way, presuming you also update your scripts to listen for the incoming midi messages needed to change your CC#.
Last edited by Dewdman42 on Tue Jun 09, 2020 8:43 pm, edited 1 time in total.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
ValliSoftware
Posts: 979
Joined: Mon May 19, 2014 10:46 am

Re: TIP: Keyswitches

Tue Jun 09, 2020 8:41 pm

GtrJazz wrote:
I’ve got lemur and metagrid


In the Lemur manual, search for "Scripting Output Functions" and locate and read each of the following:

ctlout
noteout
midiout
MacBook Pro 10.8.5 2.2 GHz Intel Core 2 Duo 6GB Ram - Logic Pro X (10.2)
MacMini 10.13.6 2GHz Intel Core i7 16GB Ram - GarageBand 10.4.5 Logic Pro X (10.4.8)
iPad Mini iOS 12 - iOS GarageBand 2.0.1
Qosimo X70-A 10.13.6 Intel® Core™ i7-4700MQ Processor 32GB DDR3L 1600MHz memory, 2-500GB 7200rpm hard drives - Logic Pro X (10.4.8)
MacMini M1 11.4 Apple M1 16GB Ram 1TB SSD Logic Pro X (10.6.2) Rosetta 2 not installed
 
GtrJazz
Posts: 103
Joined: Fri Sep 05, 2008 10:37 pm

Re: TIP: Keyswitches

Wed Jun 10, 2020 10:10 am

How do update the script to receive midi CC? I have no coding or scripting knowledge
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Wed Jun 10, 2020 10:19 am

If you decide what midi messages you want to use to control the script figure that out first and then I will show you how to adapt the scripts above for that
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
GtrJazz
Posts: 103
Joined: Fri Sep 05, 2008 10:37 pm

Re: TIP: Keyswitches

Wed Jun 10, 2020 10:38 am

[quote="Dewdman42"]If you decide what midi messages you want to use to control the script figure that out first and then I will show you how to adapt the scripts above for that[/quote]

Thanks. I’d like to use midi CC49
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Wed Jun 10, 2020 10:48 am

and have it change "what" based on which cc values?
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
GtrJazz
Posts: 103
Joined: Fri Sep 05, 2008 10:37 pm

Re: TIP: Keyswitches

Wed Jun 10, 2020 11:39 am

[quote][/quote][quote="Dewdman42"]and have it change "what" based on which cc values?[/quote]

Not sure what you mean. I’m just trying to be able to switch from the articulation view and expression views in the midi automation piano roll view. I’ll still be using my mouse to switch the articulations
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Wed Jun 10, 2020 12:18 pm

I'm sorry, but I'm not understanding your requirements so I can't recommend a solution yet.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
GtrJazz
Posts: 103
Joined: Fri Sep 05, 2008 10:37 pm

Re: TIP: Keyswitches

Wed Jun 10, 2020 1:34 pm

I’m just trying to switch between midi draw modulation, expression etc and your articulation script
Attachments
20186145-ACE2-4AC5-AE7C-25CB1D08B647.jpeg
20186145-ACE2-4AC5-AE7C-25CB1D08B647.jpeg (119 KiB) Viewed 3506 times
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Wed Jun 10, 2020 1:37 pm

This sounds like a new topic not directly related to the scripts I shared in the original post. Please create a new thread and explain exactly your requirements better(which I still don't understand well enough to offer a solution). Thanks.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Sat May 01, 2021 10:25 am

-
Last edited by Dewdman42 on Sat May 01, 2021 11:02 am, edited 1 time in total.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
User avatar
Dewdman42
Topic Author
Posts: 3270
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: TIP: Keyswitches

Sat May 01, 2021 10:31 am

-
Last edited by Dewdman42 on Sun May 02, 2021 1:23 pm, edited 1 time in total.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram