Update on scripting

I know a few people have been very keen to get involved with scripting. We’re getting close to the point we have just about killed off other issues and will be able to focus mostly on scripting environment. In the meantime some extra core functionality has been getting implemented that will make it really easy for us (a matter of a few minutes) to add new objects to scripting when necessary.

For example, here’s an example using the NoteTracker object which can tell you how many notes are currently pending (and which ones if you care)

This will be enhanced a little more so that you’ll be able to do AutoSustain, a technique where as long as you are holding more than one note down, new notes are added to the chord. When you release all notes, the chord sustains until you subsequently press a note in which case the previous chord is stopped and the new one starts. This is a mechanism that has been critical to me in both of my bands and I used to do it using MaxMSP – very happy to now have it work directly in Gig Performer

Also, here is the latest list of standard functions - growing rapidly every day

http://gigperformer.com/downloads/GPScript/SystemFunctionList.html

Making it easy to discover these functions while you’re writing a script is the key task for us next, to make scripting really easy.

Here is another script that demonstrates how to turn the global metronome on or off and adjust its volume from a rackspace.

Sigh — looking at that last example, I should have just written

EnableMetronome(newValue > 0.5)

instead of the IF THEN clause

test

Merry Christmas!

I finally had time to read the current function list. Very powerful functions and high level functionality for live purposes! I’ll do some tests in the next days.

One question about SendChordLater/SendChordNow: How is the midiMessage parameter used? I guess it contains the midi channel and velocity values for the chord notes to be sent…?

I tried it 20x times but the forum didn’t let me send my whole posting. Can’t figure out what is wrong about it…

How do we use the ProgramChangeMessage once we create it?

var PCM : ProgramChangeMessage
PCM = MakeProgramChangeMessage(5)

Assuming you have a MIDI In block called ‘foo’ that’s connected to your synth plugin, then you can write

var
foo : MidiInBlock
pcm : ProgramChangeMessage

pcm = MakeProgramChangeMessage(5) // Create a program change message
SendNow(foo, pcm) // Make the MidiInBlock foo send out the message to whatever it is connected

Having said this, the next update will have a new function called SelectPreset that can be used to set the preset of a synth plugin directly.

I tried that first but must have had a typo - was getting a compile error. Working now.

Love the idea of the SelectPreset function though :wink:

What was the compile error?

(Hint: scripting system is beta :slight_smile:

From memory it complained of an incompatible type which is why I thought the ProgramChangeMessage object was not a valid input to the SendNow() midiMessage parameter.

Is there an easy and clean way to create buttons without toggle functionality? I just thought about the case to have multiple trigger buttons “Piano”, “Organ”, “Clavinet” that are not connected to any plugin but are only handled by On WidgetValueChange callbacks (which create and send Program Change messages to some MidiInBlock).

I tried to set the max value of an LED button to 0 to see if behaves like I want, but this doesn’t work without assigning the widget to a plugin.

I’m not sure I understand the problem. You don’t have to associate a widget with a plugin to be able to use it from scripting. You can just create a widget, give it a scripting name, set up a callback and then do whatever you want from inside the callback.

For example, if you have an LED button widget called foo, you can write

var
foo : widget

on WidgetValueChange(newValue : double) from foo
Print (newValue)
end

and you’ll see its value in the script log window

Yes, I already did that (sucessfully). The only “problem” (it’s not really a problem) is that all button widgets we currently have are toggle controls so they have two state (on/off). That’s great for switching functionalities but it’s not perfect for single actions like “Send a program change” or “Play a chord” because when I click it it will change its state. It works, I just don’t want to switch the button on/off. That’s what I tried to avoid by trying to set the max value to 0…

Oh - you mean you want a non-latching button!

Yes :slight_smile:

Just checking out the

SelectPreset

function with no luck. Not sure if the code is wrong, or there’s a bug to log. Also, does the language support switch/case statements?

Cheers,

var wVB3Knob : Widget
var wVB3Name : Widget
var pVB3 : MidiInBlock

On WidgetValueChange (newValue : double) from wVB3Knob
    var i : integer
    
    // newValue represents a value between 0.0 and 1.0
    i = Floor(30.0*newValue)
    
    SelectPreset(pVB3, i)
    
    if (i == 0) then
        SetWidgetLabel(wVB3Name, "Preset #0")
    else if (i == 1) then
        SetWidgetLabel(wVB3Name, "Preset #1")
    else
        SetWidgetLabel(wVB3Name, "Preset #xx")
End
End
End

i = Floor(30.0newValue)
i will be between 0
30 and 1*30 ?

You ask for i==0 or i==1 …
I think this cannot work.

Ah I did not see the else…

I just tested, with this and it is working:

var W : Widget

On WidgetValueChange (newValue : double) from W
var i : integer

// newValue represents a value between 0.0 and 1.0
i = Floor(30.0*newValue)



if (i == 0) then
    SetWidgetLabel(W, "Preset #0")
else if (i == 1) then
    SetWidgetLabel(W, "Preset #1")
else
    SetWidgetLabel(W, "Preset #xx")

end
end
End