RepeatRepetition is one of the most fundamental of musical elaborations. In this tutorial we will introduce the repeat() method of the Mod class and show how it can be used to repeat whole phrases or sections of phrases. Here is an example of the output from the Repeat class. Below is the source code for the last example. Lets have a closer look.
The phrase is then repeated in total three more more times: Mod.repeat(phr, 3); All jMusic data types can be repeated in the same way with the Mod.repeat() methods. Next we display the phrase at that point. This allows you to visualise the repetitions and to compare with the later version of the melody. A section of the phrase is then repeated. In this example any notes between beats two and four are repeated three more times. Mod.repeat(phr, 3 ,2.0, 4.0); This form of the repeat method can be understood to act like repeat marks in a score, where the start repeat mark is at beat 2.0 and the end repeat mark is at beat 4.0. Notice that the method arguments in this method call are an extension of the ones in the more simple repeat call above. The rest of the code packs the phrase into a score,
sets an appropriate tempo, and plays the score using JavaSound. With Play.midi: parsing the false boolean
stops System.exit(0) from being called. System.exit(0) closes
everything, including window created by View.show(). Play is
imported from jm.util. |
|