Implying a sense of MeterThis program passes a phrase and adds accents on the downbeats according to the hard-coded time signature. It works regardless of the phrase's start time relative to the beginning of the score. The process is achieved by running through the following loop:
This is what the result of this tutorial file sounds like:
Let's have a closer look.
Setup all the usual jMusic stuff. Instantiate the Meter class within the main() method. Notice that the hard-coded meter is 7/8, 7/8, 7/8, 3/8.
The Meter() constructor method: Sets up a loop which makes a phrase, fills it with 100 notes (all notes in the one phrase have the same randomly selected pitch, but have different rhythmic and dynamic values), and apply the accents() method to the phrase. Once this is done, write the phrase to the part, and, when all the phrases have been created and processed, create the Score and MIDI file.
The accents() method accepts a phrase, and alters the Dynamic of particular notes within it to accent certain beats depending on the hard-coded meter. In this case, the meter (7/8, 7/8, 7/8, 3/8) is equal to 24/8 or 12/4. Hence, the beatCounter is divided by 12 and the remainder (modulus) decides if each note should be accented. This can be altered by changing the conditions of the if() statement. For example, if the meter was 3/4, the if() statement would read: if (beatCounter%3 == 0.0) n.setDynamic(127);
This would accent every third beat. Potentially, a second if command could be setup to create weaker accents on other beats. This class shows the whole process of adding accents. There is a Mod.accents()method which encapsultes all this code and can be used to add accents to a jMusic piece. Check out the details in the documentation. |
|
|
|
|
|
|