A technical support community for Apple Logic Pro users.



 
User avatar
Nseruame
Topic Author
Posts: 55
Joined: Sun Oct 09, 2016 3:48 am

New Scripter Parameter: Momentary

Tue Jul 18, 2017 10:39 pm

So... the Logic Pro X and Effects manuals are now online. Maybe I missed them before, but anyway... I noticed that with the release of Logic 10.3.2. that there is now a new momentary parameter in Scripter. I gave it a quick go, but I'm a bit puzzled. Could anyone reproduce and report back their results or opinions?

ResetPluginParameters = true

PluginParameters = [
    {
        name: "Button"
    ,   type: "momentary"
    }
,   {
        name: "Slider"
    ,   type: "lin"
    ,   minValue: 0
    ,   maxValue: 100
    ,   defaultValue: 0
    ,   numberOfSteps: 100
    }
]

/**
 * The Momentary parameter signals:
 * - pressed: NO
 * - unpressed: NO
 * - released: YES
 */
ParameterChanged = (index, value) => {
    Trace(`index = ${index}, value = ${value}`)
    
    switch(index) {
        /* always prints 1, and unlike Slider, is not announced at eval time */
        case 0: return Trace(`Button.value = ${value}`)
        case 1: return Trace(`Slider.value = ${value}`)
    }
}


To break it down, from what I've seen so far, the "momentary" button has only 1 state, and that is the release state. When you press the button, nothing happens, When you release the button, then ParameterChanged reports it as having a value of 1. Note that its not mentioned in console when the script is first run. Until now, all parameter states were reported at evaluation time (correction: except for labels!). It seems momentary is an exception.  For example, when I run the above, I get a trace saying this:

Evaluating MIDI-processing script...
Script evaluated successfully!
index = 1, value = 0
Slider.value = 0

The momentary button is not mentioned.When I press the button... nothing is reported. When I release the button after press... then the following is added to the console:
index = 0, value = 1
Button.value = 1

I would really like to know if this is reproducible, or is it just my setup. I mean... why can't the button have at least a minimum of two states, such as 'Press' (e.g. 0) and 'Release" (e.g.1 as it is). That way you could activate a randomiser for the duration of the button press... I would have thought that to be natural. I'm a little baffled! Anyone else?
 
User avatar
Jordi Torres
Moderator
Posts: 16193
Joined: Wed Jun 18, 2008 7:24 am
Location: Neuchâtel/Zürich, Switzerland

Re: New Scripter Parameter: Momentary

Sun Jul 30, 2017 9:35 am

Hi,

Over here it works like you describe. Seems weird to me as well that it only outputs a single value.

Totally unrelated: I cannot get ES6 arrow functions to work in Scripter like you have there for the ParameterChanged function...maybe because I'm still running OS 10.11.6?

Other ES6-related features do work however (template literals, const declarations...although let doesn't, surprisingly)...

J.
Et voilà!

Mac mini i7 2.3 GHz - 16GB RAM | OS 10.12.6 | Logic Pro 10.3.2
MacBook Pro 15" Retina i7 2.2 GHz - 16GB RAM | OS 10.12.6 | Logic Pro 10.3.2
RME Fireface 400 | Akai MPK49 | Nord Micro Modular
 
User avatar
Nseruame
Topic Author
Posts: 55
Joined: Sun Oct 09, 2016 3:48 am

Re: New Scripter Parameter: Momentary

Sun Jul 30, 2017 11:19 am

@Jordi - thanks for the feedback. Almost relieved that you also find it weird. Haven't put too much thought into use cases.

Moving on... as always, fascinated by the language that never works. So, let me get this straight - the const keyword is an ES5 keyword AFAIK, so not too surprised by that one... but template literals ARE supported by the JavaScriptCore on OS X Yosemite 10.11.6?

This works?
Trace(`The time is ${Date.now()}`)

But this does not?
let value = true
Trace(value)


Curiosity is big, but investigating various Logic Pro X / JavaScriptCore and OS variations without access to those configurations myself would probably not be a good idea. All I can really suggest is that hacking or attempting to update or bypass the os framework:
 
/System/Library/Frameworks/JavaScriptCore.framework

is most likely a more tricky and non-recommendable path that updating the OS, yet the effects of updating the OS has very real and annoying issues in a music production context on Apple products (for me to date, at least). I see that you have the latest stable release of Yosemite, right? When was that released? I wonder if that shipped with a more recent JavaScriptCore.

Thinking out loud, I wonder if a poll involving ES5/6 support on JavaSctiptCore in Scripter would be useful to anyone? 

DISCLOSURE :
It is my assumption through testing and upgrade experiences, but without any concrete proof, the Logic Pro X uses the system JavaScriptCore. I think its a rational assumption but am open to suggestion. Also, apart from just outright curiosity, I have to disclose some personal interest in a poll like that as I'm writing an ES6 Scripter library at the moment and I would like to be sure of which platform combinations would suit it. I'm pretty confident that I could keep it ES6 based and have it transpile to an ES5 output during the build process if there was any need.
 
User avatar
Jordi Torres
Moderator
Posts: 16193
Joined: Wed Jun 18, 2008 7:24 am
Location: Neuchâtel/Zürich, Switzerland

Re: New Scripter Parameter: Momentary

Mon Jul 31, 2017 12:06 am

Hi,

Nope, let and const declarations are both Ecmascript 2015 (AKA ES6). Template literals (also ES6) work fine in Scripter.
My question was specifically about arrow functions. You have them in your code example but arrow functions don't work for me in Scripter:

Screen Shot 2017-07-31 at 09.05.08.png
Screen Shot 2017-07-31 at 09.05.08.png (61.22 KiB) Viewed 412 times


J.
Et voilà!

Mac mini i7 2.3 GHz - 16GB RAM | OS 10.12.6 | Logic Pro 10.3.2
MacBook Pro 15" Retina i7 2.2 GHz - 16GB RAM | OS 10.12.6 | Logic Pro 10.3.2
RME Fireface 400 | Akai MPK49 | Nord Micro Modular
 
User avatar
Nseruame
Topic Author
Posts: 55
Joined: Sun Oct 09, 2016 3:48 am

Re: New Scripter Parameter: Momentary

Mon Jul 31, 2017 3:30 am

@Jordi - my bad - I could have sworn I used const in an ES5 context in the past, but then again, I avoided ES5 like the plague. You are right - the formal specification for const arrived with ES6! Anyhow - more awake now. I hear you with regard to arrow functions and see the conundrum - it would seem that whatever version of JavaScriprCore you have seems to have mixed support for both language editions. Madness! If you can pick out that level of detail, you know that you could refactor the function declaration... but man, that type of thing (Scripter and JavaScript idiosyncracies) has driven me mad, thus the library concept. I don't know how to fix that rather than update to Sierra, but that's pretty drastic. Thanks for the insight. Will investigate feasibility of transpiling build from ES6 to ES5/4. Bloody annoying state of affairs!
 
User avatar
Jordi Torres
Moderator
Posts: 16193
Joined: Wed Jun 18, 2008 7:24 am
Location: Neuchâtel/Zürich, Switzerland

Re: New Scripter Parameter: Momentary

Mon Jul 31, 2017 2:19 pm

Hi,

Nseruame wrote:
 I don't know how to fix that rather than update to Sierra, but that's pretty drastic. 


That did it! :)

Thanks for the hint.

J.
Et voilà!

Mac mini i7 2.3 GHz - 16GB RAM | OS 10.12.6 | Logic Pro 10.3.2
MacBook Pro 15" Retina i7 2.2 GHz - 16GB RAM | OS 10.12.6 | Logic Pro 10.3.2
RME Fireface 400 | Akai MPK49 | Nord Micro Modular
 
User avatar
Nseruame
Topic Author
Posts: 55
Joined: Sun Oct 09, 2016 3:48 am

Re: New Scripter Parameter: Momentary

Tue Aug 01, 2017 5:01 am

Nice one Jordi :)
 
User avatar
Unheardofski
Posts: 132
Joined: Fri Jan 16, 2015 6:13 am
Location: Stockholm, Sweden

Re: New Scripter Parameter: Momentary

Thu Aug 10, 2017 3:03 am

Hi guys,

Back at a computer. As far as I can tell the reason for this (other than cosmetically nice button) is to not have it fire (as opposed to a checkbox) when the script initialises (*explanation below)
*When using a chechbox for a button, I usually go SetParameter(p,0) in callback instantly to mimic a button. This makes the callback fire straight away on running script.


I just used it in a custom script for a client. 
Before "momentary" I had to put in a "firstRun" variable to avoid PluginParameter callbacks firing on initialise.
In the script I am making right now, without momentary or a "firstRun" variable, the script would fire a fade of a CC value instantly upon running which would kill the whole purpose.

Am I making sense?
http://www.logicscripts.net
My website with both free and commercial scripts for Logic Pro X.
Logic 10.3.1 | OS X 10.12.4 | MacBook Pro (Retina, 13-inch, Early 2015) | 2,7 GHz Intel Core i5 | 8 GB 1867 MHz DDR3 |
Propellerhead Balance | Ableton PUSH 2 | Novation Launchkey 25 | Akai MPC Keys | M-Audio Oxygen 25 Blue | Akai LPK25
 
User avatar
Dewdman42
Posts: 274
Joined: Tue Sep 09, 2014 3:01 pm
Location: Park City, UT

Re: New Scripter Parameter: Momentary

Thu Aug 10, 2017 8:42 pm

I think the purpose of this UI element is simple, its a button, nothing more.  It doesn't keep state or anything.  Its just something you can click on the UI and when you do, ParameterChanged() will be called showing a value of 1 that it was clicked on (and released).  Do whatever you want with that.

Could be useful as a panic button, for example, stuff like that where you just hit it and specifically DON'T want any kind of state to change.

PluginParameters = [
    {
        name: "PANIC"
    ,   type: "momentary"
    }
]

function ParameterChanged (index, value) {
   
   if (index == 0) {
      MIDI.allNotesOff();
   }
}

function HandleMIDI(event) {
   event.send();
   event.trace();
}

But one thing that is annoying is that the label for the button and the text on the actual button is the same... which is kind of redundant, unless there is some way to make the text on the button different then the name of UI control.
MBP i7 2.66ghz, MacPro 3.3ghzx12, OSX 10.12, Logic Pro 10, Mainstage3, too many plugins to list
 
User avatar
Nseruame
Topic Author
Posts: 55
Joined: Sun Oct 09, 2016 3:48 am

Re: New Scripter Parameter: Momentary

Mon Aug 14, 2017 1:45 pm

Apart from MIDI panic, it could be handy for GUI management e.g. setting parameter states, default values or otherwise
PluginParameters = 
[
    {
        name: "Change GUI State",
        type: "momentary"
    }
,   {
        name: "Setting",
        type: "menu",
        defaultValue: 0,
        valueStrings: [
            "Off ", "On"
        ]
    }
,   {
        name: "Velocity",
        type: "lin",
        defaultValue: 50,
        minValue: 0,
        maxValue: 100,
        numberOfSteps: 10
    }
]

ParameterChanged = ( index, value ) => {
    switch ( index ) {
        case 0: {
            if (0 === GetParameter(1)) {
                SetParameter( 1, 1 )
                SetParameter( 2, 0 )
            } 
            else {
                SetParameter( 1, 0 )
                SetParameter( 2, 100 )
            }    
        }
    }
}

It is definitely annoying that the buttons text duplicates the buttons label. 
 
User avatar
Unheardofski
Posts: 132
Joined: Fri Jan 16, 2015 6:13 am
Location: Stockholm, Sweden

Re: New Scripter Parameter: Momentary

Fri Aug 18, 2017 1:48 pm

Dewdman42 wrote:
I think the purpose of this UI element is simple, its a button, nothing more.  It doesn't keep state or anything.  Its just something you can click on the UI and when you do, ParameterChanged() will be called showing a value of 1 that it was clicked on (and released).  Do whatever you want with that.

Yeah, that's basically what I was saying. Earlier you had to jump through some hoops to make the checkbox stand in as a button. For any sort of commercial programming this Parameter is useless because nobody has the latest update ever and you can forget about MainStage users.
http://www.logicscripts.net
My website with both free and commercial scripts for Logic Pro X.
Logic 10.3.1 | OS X 10.12.4 | MacBook Pro (Retina, 13-inch, Early 2015) | 2,7 GHz Intel Core i5 | 8 GB 1867 MHz DDR3 |
Propellerhead Balance | Ableton PUSH 2 | Novation Launchkey 25 | Akai MPC Keys | M-Audio Oxygen 25 Blue | Akai LPK25
 
User avatar
Dewdman42
Posts: 274
Joined: Tue Sep 09, 2014 3:01 pm
Location: Park City, UT

Re: New Scripter Parameter: Momentary

Fri Aug 18, 2017 3:25 pm

what do you mean when you say "you can forget about mainstage"?  Does latest mainstage not include momentary type, or are you referring more to the users?  

I recently had a lot of problems with Scripter using 10.3.2 on El Capitan and basically was forced to upgrade to Sierra, now it works perfectly.  It was crashing Logic regularly under El Capitan.  

I am having a hard time coming up with a real need for the momentary switch anyway, but maybe I will think of something eventually.
MBP i7 2.66ghz, MacPro 3.3ghzx12, OSX 10.12, Logic Pro 10, Mainstage3, too many plugins to list