Exemple #1
0
 @Test
 public void test() {
   Score score = getScore();
   MP mp = mp0;
   for (int i = 0; i < expectedChords.length; i++) {
     Chord chord = (Chord) score.getVoice(mp).getElementAt(mp.beat);
     assertEquals("chord " + i, expectedChords[i].getNotes(), chord.getNotes());
     assertEquals("chord " + i, expectedChords[i].getDuration(), chord.getDuration());
     mp = mp.withBeat(mp.beat.add(expectedChords[i].getDuration()));
     if (mp.beat.compareTo(_1) >= 0) {
       mp = mp.withMeasure(mp.measure + 1).withBeat(_0);
     }
   }
 }
Exemple #2
0
 @Test
 public void test() {
   for (int iMeasure : range(3)) {
     for (int iElement : range(iMeasure == 2 ? 3 : 4)) {
       MP mp = MP.atElement(0, iMeasure, 0, iElement);
       Chord chord = ChordTest.getChordAt(score, mp);
       assertEqualsChordLyrics(expectedLyrics[iMeasure * 4 + iElement], chord, mp);
     }
   }
 }
Exemple #3
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;
 }