> MIDI > Musical Data > Gamelan | |||||
GamelanThe music of the Balinese Gamelan is a loop-based music which lends itself
well to computer music implementations. This is what the result of this tutorial file sounds like:
Let's have a closer look.
This class has two methods: The main() method above, and the makePhrase() method below that does most of the work. In this composition one part is created and filled with numerous phrases. Each phrase is similar but varies due to some random selection of pitches and rhythms. The randomness is limited to those values in the mode and rhythm arrays. This is an effective technique to constrain the stochastic process within certain limits. static int[] mode = {0,1,3,7,8}; static double[] rhythm = {1.0,2.0}; The loop in the main method calls the makePhrase() method each time around and adds the newly created phrase to the part p. The part is then added to a score which is translated to a MIDI file format and saved as a MIDI file called "gamelan.mid".
This method takes an argument that determines the number of notes to put in the phrase. The for-loop repeats the required number of times to create a note each time around. The internal loop and if statement looks a little complex but, in short, checks to see if the chosen note is in the pitch class set specified by the mode array. 0 = any C, 1 = any C#, 3 = any D#, and so on. The internal for loop goes through each element in the mode array, and if it finds a match the note is added to the phrase, otherwise a new pitch is selected. Because the "scale" required is non-western this process is necessary
in full. Notice the return statement at the end of the makePhrase() method.
public static Phrase makePhrase(int howManyNotes) { If a method does not return a value - like the main() method does not - then the return type is declared to be void. |
|||||