Ejemplo n.º 1
0
 /**
  * Creates a score with a single staff, two measures, and a number of clefs, keys and chords. The
  * score, the list of clefs and the list of keys is returned.
  */
 private Tuple3<Score, List<Clef>, List<Key>> createTestScoreClefsKeys() {
   // create two measures:
   // clef-g, key-Gmaj, C#1/4, clef-f, Db1/4, clef-g, key-Fmaj, Cnat1/4 |
   // C#1/4, key-Cmaj, clef-f, C2/4.
   Score score = ScoreFactory.create1Staff();
   new MeasureAdd(score, 1).execute();
   List<Clef> clefs = new ArrayList<Clef>();
   List<Key> keys = new ArrayList<Key>();
   Clef c;
   Key k;
   // measure 0
   Measure measure = score.getMeasure(atMeasure(0, 0));
   new Clef(ClefType.clefTreble);
   clefs.add(c = new Clef(ClefType.clefTreble));
   new MeasureElementWrite(c, measure, fr(0, 4)).execute();
   keys.add(k = new TraditionalKey(1, Mode.Major));
   new MeasureElementWrite(k, measure, fr(0, 4)).execute();
   new VoiceElementWrite(
           measure.getVoice(0), atElement(0, 0, 0, 0), chord(pi(0, 1, 4), fr(1, 4)), null)
       .execute();
   clefs.add(c = new Clef(ClefType.clefBass));
   new MeasureElementWrite(c, measure, fr(1, 4)).execute();
   new VoiceElementWrite(
           measure.getVoice(0), atElement(0, 0, 0, 1), chord(pi(1, -1, 4), fr(1, 4)), null)
       .execute();
   clefs.add(c = new Clef(ClefType.clefTreble));
   new MeasureElementWrite(c, measure, fr(2, 4)).execute();
   keys.add(k = new TraditionalKey(-1, Mode.Major));
   new MeasureElementWrite(k, measure, fr(2, 4)).execute();
   new VoiceElementWrite(
           measure.getVoice(0), atElement(0, 0, 0, 2), chord(pi(0, 0, 4), fr(1, 4)), null)
       .execute();
   // measure 1
   measure = score.getMeasure(atMeasure(0, 1));
   new VoiceElementWrite(
           measure.getVoice(0), atElement(0, 1, 0, 0), chord(pi(0, 1, 4), fr(1, 4)), null)
       .execute();
   keys.add(k = new TraditionalKey(0, Mode.Major));
   new MeasureElementWrite(k, measure, fr(1, 4)).execute();
   clefs.add(c = new Clef(ClefType.clefBass));
   new MeasureElementWrite(c, measure, fr(1, 4)).execute();
   new VoiceElementWrite(
           measure.getVoice(0), atElement(0, 1, 0, 1), chord(pi(0, 0, 4), fr(2, 4)), null)
       .execute();
   return t3(score, clefs, keys);
 }
Ejemplo n.º 2
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;
 }