> Music Algorithms > Modifying > Up - Down, Left - Right | ||||||||
Up - Down, Left - Right
This tutorial describes a class that generates a phrase then creates a (not so intelligent) structure from it through transposition to shift the notes up and down, and copying and pasting to different locations to show moving left and right in time. Here is a score generated by this program:
This tutorial concerns the class ShiftAround.java Click here to view the source. Lets have a closer look.
In order to make use of the jMusic constants we import the jm.JMC class. To use Note, Phrases, Parts, and Scores we import the jm.music.data package. The Mod class is in the jm.music.tools package. In order to see and hear the score we use the View and Write classes in the jm.util package.
After declaring the class we start the main() method. In this one-method class all the action happens in the main() method. First up we declare some method variables for the score, part, and phrase.
This section of code shows a melodic sequence. It is created by copying
and transposing the riff a couple of times. A melodic sequence is a useful compositional device, and not hard to achieve as you can see.
This next section of code creates copies of the riff, sets them to start at a random location in time and adds them to a new part with a randomly selected instrument. There are plenty of comments in the code to let you know what each line
does. Most importantly you should notice that jMusic composition can include
a combination of deterministic composition (the creation of the riff)
and some stochastic elements (the start times of the copied riffs).
The score is shaken - but not stirred :) - which is a Mod method that randomises the dynamic value of each note a bit, which makes it sound somewhat less mechanical on playback. Although the setting in this example, 50, is quite extreme. The score is shown in a hybrid notation/piano roll display, as above, then written out to a MIDI file for auditioning. |
||||||||