Wind ChimesThis was one of the earliest jMusic pieces, and so is considered a 'classic' in the jMusic community. It is quite simple but effective - like all good music. The class simulates the random-like polyphony of metallic wind chimes. There are several pitches (length of tube) and each employs random rhythms and dynamics. This is what the result sounds like Let's have a closer look.
Four phrases area created, each of 24 notes added with random rhythm values in one large for-loop. Notice that the pitches are set, which corresponds to a four ringer wind chime. The rhythm values and dynamic of each note is set using the Math.random() function. This function gives a result between zero and one and is scaled by multiplying as required. An important programming point here is that the arguments passed to methods (such as the Note constructor) can be computed as we go. In previous tutorials we have often used set values. Each phrase is added to the same part - they all play on the same instrument so there is no need for separate parts. The part is added to a score which is then translated to a MIDI file format and written to disk. A sample output from this class is on the jMusic home page as a looped MIDI file. Because of the stochastic nature of the rhythm, little sense of repetition is perceived and the looped music sounds quite continuous. A neat psychoacoutsic trick. |