Tutorial

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

Score 101 - Combining notes, phrases and chords. Reload page to restart example
The SCScore class provides a temporal container for notes, phrases, chords, and callbacks. Objects are added to the score at a particular start time (in beats per minute) and the score can be played or looped as required.

Scores allow for the construction of complex musical sections. Several scores can be created if desired, and callbacks could be used to trigger a sequence of scores allowing for a flexible structuring of musical works.

This example is quite extensive and demonstrates a number of algorithmic music techniques as well as how to add things to a score, so it may be worth a close inspection. In essence, how to add notes to a score is covered in the first 5 lines, but that would be a pretty boring score to listen to :)



After importing the SoundCipher libaray a new SCScore object is created. Notice that unlike most other tutorial examples that use the immediate playback functions of the SoundCipher class (such as playNote), this program does not need to instantiate a SoundCipher object.

For musical purposes a pitch class set, called pitches, is established as an array. It is used for constructing the pitched material in latter sections.

The kick drum section shows a simple way of adding notes to a score. The arguments to addNote are:

    score.addNote(startTime, channel, instrument, pitch, dynamic, duration, articulation, pan);

The hi hats section also uses addNote() inside a for-loop as an convenient way to add many notes. Notice that the drum sounds are on MIDI channel 9. The cosine function for dynamic looks a bit complicated but is a neat trick to vary the dyanmic of each note programatically.

The bass section shows how to add a phrase to the score. It has to be acknowledged that this is a bit cumbersome given all the arrays of paramters, but when more or longer phases are implemented the ratio of lines of code to number of notes created starts to get better - in this example we only produce a phrase of 4 notes. The if-statement inside the for-loop is a neat way to ensure that the downbeat is treated differently to other beats which is often useful musically.

The piano section constructs a chord from the pitch class set and adds it to the score a couple of times.

Finally the score is played with 3 repeats.

Because of the heavy use of randomness in this example it is worth refreshing the page to restart the applet and hear how this code produces a variety of generated scores.