Where can I find useful examples of functions and the scripting language in general?
There is this blog post:
https://gigperformer.com/the-gpscript-programming-language/
On the online manual:
https://gigperformer.com/docs/Userguide36/gpscriptintro.html
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.
Most of my learning of gp script came from simply reviewing the function list:
https://gigperformer.com/downloads/GPScript/SystemFunctionList.html
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.
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?
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.
⦠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!
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.
Me too!
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
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?
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:
https://gigperformer.com/downloads/GPScript/SystemFunctionList.html
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.