Exemplo n.º 1
0
 private boolean isAnyTiedTo(TGNote note) {
   TGMeasure measure = note.getBeat().getMeasure();
   TGBeat beat = this.manager.getMeasureManager().getNextBeat(measure.getBeats(), note.getBeat());
   while (measure != null) {
     while (beat != null) {
       // If is a rest beat, all voice sounds must be stopped.
       if (beat.isRestBeat()) {
         return false;
       }
       // Check if is there any note at same string.
       Iterator it = beat.getNotes().iterator();
       while (it.hasNext()) {
         TGNote current = (TGNote) it.next();
         if (current.getString() == note.getString()) {
           return current.isTiedNote();
         }
       }
       beat = this.manager.getMeasureManager().getNextBeat(measure.getBeats(), beat);
     }
     measure = this.manager.getTrackManager().getNextMeasure(measure);
     if (measure != null) {
       beat = this.manager.getMeasureManager().getFirstBeat(measure.getBeats());
     }
   }
   return false;
 }
Exemplo n.º 2
0
  private void addBeat(int key, TGBeat beat) {
    if (beat.isRestBeat()) {
      this.writer.print("r");
      this.addDuration(beat.getDuration());
    } else {
      int size = beat.countNotes();
      if (size > 1) {
        this.writer.print("<");
      }
      for (int i = 0; i < size; i++) {
        TGNote note = beat.getNote(i);

        int note_value =
            (note.getBeat().getMeasure().getTrack().getString(note.getString()).getValue()
                + note.getValue());
        this.addKey(key, note_value);
        if (!(size > 1)) {
          this.addDuration(beat.getDuration());
        }
        this.addString(note.getString());
        if (this.isAnyTiedTo(note)) {
          this.writer.print("~");
        }

        if (size > 1) {
          this.writer.print(" ");
        }
      }
      if (size > 1) {
        this.writer.print(">");
        this.addDuration(beat.getDuration());
      }

      if (beat.isChordBeat()) {
        this.writer.print("-\\tag #'chords ^\\markup \\fret-diagram #\"");
        TGChord chord = beat.getChord();
        for (int i = 0; i < chord.countStrings(); i++) {
          this.writer.print((i + 1) + "-" + getLilypondChordFret(chord.getFretValue(i)) + ";");
        }
        this.writer.print("\"");
      }

      if (beat.isTextBeat()) {
        this.writer.print("-\\tag #'texts ^\\markup {" + beat.getText().getValue() + "}");
      }

      if (beat.getMeasure().getTrack().getLyrics().getFrom() > beat.getMeasure().getNumber()) {
        this.temp.addSkippedLyricBeat(getLilypondDuration(beat.getDuration()));
      }

      this.writer.print(" ");
    }
  }