Much attention in these tutorials has been placed on the note pitch, however this demo explores aleatoric (randomly influenced music/art) note durations.
To hear the result play this midi file.
Humans are quite susceptible to changes in timing, and the apparent disorganisation of this random series of rhythms confirms this.
To read a comprehensive background of randomness and automatic processes in music composition with computer check out chapter 10 "Automata" in Joel Chadabe's book "Electric Sound: The past and promise of electronic music." Prentice Hall, 1997.
Lets have a closer look.
Lines 1-4 import useful packages that we need
to use in the program. The first import statement gets a standard Java
class. The rest of the statements import the jMusic classes (to take
another look at the package documentation or work out what gets imported from where look at the
In this section score, part, and phrase objects are
24 notes are added to the phrase. Each note is of
the same pitch (snare drum for General MIDI instruments on channel 10)
and MIDI channel. They are each given a random duration between 0.0 and
4.0 (nothing and a whole note).
The phrase is added to a part, which in turn is
allocated to the score. A score object is required for passing to the
MIDI file conversion class.
As with other jMusic demo files, this code creates
a MIDI file from the score. Once created the randomRhythm.mid file can
be played by any MIDI file player and will sound correctly using a
General MIDI sound source, such as most PC sound cards, or Quicktime.
The final line provides feedback during execution that the MIDI file has
been successfully written.