Exemple #1
0
  public static void main(String[] args) {
    Phrase phr = new Phrase();

    // create a random walk
    int pitch = 60;
    for (int i = 0; i < 12; i++) {
      Note n = new Note(pitch += (int) (Math.random() * 8 - 4), SQ * (int) (Math.random() * 2 + 1));
      phr.addNote(n);
    }

    // repeat the whole thing three times
    Mod.repeat(phr, 3);

    // see the result at this stage
    View.show(phr);

    // repeat beats 2 - 4 three times
    Mod.repeat(phr, 3, 2.0, 4.0);

    // see the result of this change
    View.show(phr, 50, 50);

    // hear the result
    Part p = new Part();
    Score s = new Score();
    p.addPhrase(phr);
    s.addPart(p);
    s.setTempo(140.0);

    Play.midi(s, false);
    // false so that it doesn't close everything, the view.show() window
    // in particular

    Write.midi(s, "Repeat.mid");
  }
Exemple #2
0
 public void transform() {
   // Bird
   for (int i = 0; i < bird_num; i++) {
     note =
         new Note(
             bird_jnote[i].pitch, (double) bird_jnote[i].duration / 120, bird_jnote[i].velocity);
     bird_phrase.addNote(note);
   }
   bird_phrase.setStartTime(start_time * 4.0);
   bird_part.empty();
   bird_part.addPhrase(bird_phrase);
 }