Procedures (chunks)
Procedures in Handel are called chunks. You can conceptualize a chunk as a song track. When ran, chunks play at the same time as other run chunks and the global track. Chunks must begin with the chunk keyword and end with the endchunk keyword.
Below is an example program with a kick drum and a piano, playing together.
Both the 'backbeat' chunk and the 'mykeys' chunk above play together (not one after the other). This behavior allows multitrack songs to be created with Handel.
Note that each chunk has its own scope.
#
More on procedures (chunks) and their syntax#
Procedure declaration (creating chunks)As noted above you can create chunks with the chunk keyword. The name of the chunk (the chunk name) follows the keyword.
This chunk name must be all lowercase letters, no numbers and cannot be one of Handel's reserved keywords. (See the Reserved Keywords section below).
After the chunk name, you can optionally add parameters. A list of comma separated parameters can follow the using keyword.
Together you get the following: chunk somechunkname using someparam, anotherparam
After the optional parameter list, you can add a body to the chunk. This is a function body (what you would like to happen when the chunk is ran).
Lastly the chunk must be ended with the endchunk keyword.
#
Running ProceduresThere are two ways to run a chunk in Handel.
You can run a chunk using the run keyword. This conceptually creates a new song track, and plays the chunk synchronously with all running chunks.
You can also run a chunk using the call keyword. This runs the chunk in place (in the songtrack the chunk is called in).
The syntax for running a chunk is the run or call command followed by the name of the chunk.
If the chunk has parameters, a you must use the `using
keyword followed by a matching number of comma separated arguments.
Here is an example running two chunks. One chunk requires arguments the other does not.
The run command is used to run noargs in its own conceptual song track.
Within noargs
, 1 note plays, and the playtwo
chunk is called in place.
Note that saved variables (containing any built-in type in Handel), digits, playables, durations, can be used as arguments when running a chunk.
OK! Now to configuring a run of a chunk.
#
Configuring a run of a chunkYou can configure a run of chunk by adding the with keyword and a comma separated list of customizations to the end of a run command.
There are three main customizations: bpm, sound, and loop.
You can use bpm keyword to set the bpm of a run of a chunk.
For example bpm 120
You can use the sound keyword to set the instrument of a run of a chunk.
For example sound piano
The current available sounds to choose from are: piano, synth, casio, kick, snare, hihat
You can use the loop keyword to set the amount of times the run of a chunk shoud loop for.
For example loop for 10
All together you can configure a run of a chunk as follows:
Above we've got a chord, played with a piano, looping 8 times, with a bpm of 100!
(see reference below for addition customizations)