Examples Please?

Where can I find useful examples of functions and the scripting language in general?

There is this blog post:

On the online manual:

1 Like

I have read the documentation and only a few of the functions come with examples. Each GP function should have at least one example of how to use the function.

For example, I see on the following statement “on NoteEvent(m : NoteMessage) from M1” where “m” is the notes that were just played on the NoteEvent Callback … what I would like to see in the documentation is an example: how I can:

1)  grab the individual notes out of "m" and place them into an array so I can - 
1) manipulate and add to them and then send them back out.
1 Like

Most of my learning of gp script came from simply reviewing the function list:

For example, the ‘MIDI’ and ‘System’ sections should include everything relevant for processing the midi message you receive in the On NoteEvent callback.

Otherwise, searching one of these functions in the forum will usually bring up a lot of nice examples.

That’s probably not going to happen, certainly not in the short term. GP Script is intended for advanced users who are already familiar with programming concepts (e.g, variables, types, statements, functions) and the documentation is intended to be a reference manual, it is not intended to be a tutorial or to teach people programming. Our assumption is that anyone familiar with these concepts will be able to browse the list of system functions to find what they need so as to create a solution for their particular needs, as @rank13 already observed.

There are arbitrary possible examples, and no matter what we might include, someone will want something else. For example, if I was going to include an example of how to use the NoteEvent callback, I would have probably just shown how to transpose an incoming message. That would provide absolutely no help to someone wanting to know how to put messages into an array.

The whole purpose of this “Scripting with Gig Performer” category is so that people can help each other with particular problems that need to be solved.

“m” represents a single message as described in the documentation. There can’t be more than one note message in such a callback.


1 Like

By the way, there are quite a few built in objects such as the NoteTracker which might be useful.

Also, there are significant improvements in the GP4 version of GP script which will be helpful as well.

Really? :stuck_out_tongue_winking_eye:


I meant to GP Script

I can respect you saying, “it is not intended to be a tutorial…”. No one expects you to teach programming nor write scripts. Just a one or two-line example for each function placed right below the syntax would be nice and clear up a lot of questions. If you were to add more code template blocks accessible in the editor in addition to the very basic ones you have now, it would be greatly appreciated.

As for my example regarding “m(NoteMessage)” … I would just like clarification of what the primitive “m” is? Is “m” a string, array[1], array[2], vcar, etc. … also maybe just two lines of code showing how to use “m” or how to cast it to another useful object.

If you can’t afford the time to do short examples for functions, would you consider reserving a searchable file section where people can place their scripts. For the most part, I feel guilty about asking for help on my scripts … but as long as the community can tolerate my questions, I will go this route. :slight_smile:


… For the most part, I feel guilty about asking for help on my scripts … but as long as the community can tolerate my questions, I will go this route.

Just go ahead and ask… the worst case could be that you won’t get an answer - which i honestly doubt! :slight_smile:


There is already:

And there will be some more…

Edit: that’s is you can do a search in this categorie.

To be honest, i am missing those “short examples” too in the docs, but i can also see the point of our devs…
I could imagine that maybe a “Wiki” system could be helpful for this… so the users could write their own examples and maybe one day, those code snippets could become part of the “real” manual… just thinking. :slight_smile:


Me too! :nerd_face:

1 Like

Did you notice that when you do a right click (Win) when in the script editor, you can choose among many code templates and example? With this and the documentation there are a lot of possibilities…

Don’t feel guilty, and ask, that’s the purpose of a community forum :wink:

If you refer to e.g. this in the manual:

It means that the type of m is NoteMessage. So what is a NoteMessage, well… as you can imagine, it is a MIDI message representing a single note.


Yeah, we’ve tried hard to use clear names (even if they’re long) for types and functions so as to make them be self-documenting.

“GP Script is intended for advanced users who are already familiar with programming concepts”

I would be grateful for someone to point me in the direction of what programming concepts are required and what to learn to become an advanced user.

That’s a great question. There are so many online tutorials as well as books out there…and while many languages are technically similar under the covers, the ones you must frequently see today are (IMO) far more complicated to learn than they ought to be.

For what it’s worth, I used the concepts in languages like Pascal, Algol when I designed GP Script. These are really old languages (from the '60s and '70s) but Pascal in particular was originally designed as a teaching language so following a beginning tutorial on Pascal might be easier than dealing with languages like Javascript or C/C++ etc.

Perhaps take a look perhaps at this:

The basic concepts such as data types, variables, decision making, loops, functions are extremely similar to what you see in GP Script.


I know m is a NoteMessage … and I know what a NoteMessage should contain. I just don’t know how to parse it because it’s properties are not discussed and defined in the language syntax. EG: How does one access and/or change the velocity, channel, aftertouch or note value in the NoteMessage?

1 Like

As I mentioned above, I was able to look through the function list to find what I needed. The MIDI section is the exhaustive list of everything that’s available:

e.g. to extract the channel number:

GetChannel : Returns the MIDI channel number (between 1 and 16) of any MIDI message

  • Declaration: function GetChannel (m : MidiMessage) Autotype returns Integer

To edit the channel number:

WithChannel : Changes the channel number of any MIDI event.

  • Declaration: function WithChannel (m : MidiMessage, channel : int) autotype returns MidiMessage

This is good to know, however following the syntax of “On NoteOnEvent(m) From SomeMidiInBlock” there should be a “see also” reference to related functions. This is the proper way to document a language rather than have the user search all the documentation in hopes he will find the specific function he needs.