Exemple #1
0
 /**
  * Creates a score with a single staff, two measures with each two voices, with key changes and
  * chords with accidentals.
  */
 private Score createTestScoreAccidentals() {
   // create two measures with two voices:
   //           measure 0    | measure 1
   // beat:      0      1     | 0        1
   // key:       Gmaj         | *Fmaj    Cmaj
   // voice 0:   C4           | F#4      Bb4 Bb4
   // voice 1:   Fnat4        | Bb4      F#4 F#4
   // (*) is a private key (not in measure column)
   Score score = ScoreFactory.create1Staff();
   new MeasureAdd(score, 1).execute();
   new VoiceAdd(score.getMeasure(atMeasure(0, 0)), 1).execute();
   new VoiceAdd(score.getMeasure(atMeasure(0, 1)), 1).execute();
   // keys
   new ColumnElementWrite(
           new TraditionalKey(1, Mode.Major), score.getColumnHeader(0), fr(0, 4), null)
       .execute();
   new MeasureElementWrite(
           new TraditionalKey(-1, Mode.Major), score.getMeasure(atMeasure(0, 1)), fr(0, 4))
       .execute();
   new ColumnElementWrite(
           new TraditionalKey(0, Mode.Major), score.getColumnHeader(1), fr(1, 4), null)
       .execute();
   // measure 0, voice 0
   Voice voice = score.getVoice(MP.atVoice(0, 0, 0));
   voice.addElement(chord(pi(0, 0, 4), fr(2, 4)));
   // measure 1, voice 0
   voice = score.getVoice(MP.atVoice(0, 1, 0));
   voice.addElement(chord(pi(3, 1, 4), fr(1, 4)));
   voice.addElement(chord(pi(6, -1, 4), fr(1, 8)));
   voice.addElement(chord(pi(6, -1, 4), fr(1, 8)));
   // measure 0, voice 1
   voice = score.getVoice(MP.atVoice(0, 0, 1));
   voice.addElement(chord(pi(3, 0, 4), fr(2, 4)));
   // measure 1, voice 1
   voice = score.getVoice(MP.atVoice(0, 1, 1));
   voice.addElement(chord(pi(6, -1, 4), fr(1, 4)));
   voice.addElement(chord(pi(3, 1, 4), fr(1, 8)));
   voice.addElement(chord(pi(3, 1, 4), fr(1, 8)));
   return score;
 }