Jump to content

New Scripter Parameter: Momentary


Recommended Posts

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?

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

@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!
Link to comment
Share on other sites

  • 2 weeks later...

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...