private void addSong(TGSong song) {
    int trackCount = song.countTracks();
    if (this.settings.isTrackGroupEnabled() && trackCount > 1) {
      this.writer.println("\\score {");
      if (this.settings.getTrack() == LilypondSettings.ALL_TRACKS) {
        this.writer.println(indent(1) + "<<");
      }
    }

    for (int i = 0; i < trackCount; i++) {
      TGTrack track = song.getTrack(i);
      if (this.settings.getTrack() == LilypondSettings.ALL_TRACKS
          || this.settings.getTrack() == track.getNumber()) {
        if (!this.settings.isTrackGroupEnabled() || trackCount == 1) {
          this.writer.println("\\score {");
        }
        this.writer.println(indent(1) + "\\" + this.trackID(i, "StaffGroup"));
        if (!this.settings.isTrackGroupEnabled() || trackCount == 1) {
          this.addHeader(song, track.getName(), 1);
          this.writer.println("}");
        }
      }
    }

    if (this.settings.isTrackGroupEnabled() && trackCount > 1) {
      if (this.settings.getTrack() == LilypondSettings.ALL_TRACKS) {
        this.writer.println(indent(1) + ">>");
      }
      this.addHeader(song, null, 1);
      this.writer.println("}");
    }
  }
 private void addStaffGroup(TGTrack track, String id) {
   this.writer.println(id + "StaffGroup = \\new StaffGroup <<");
   if (this.addTrackTitleOnGroup(track.getSong())) {
     this.writer.println(
         indent(1) + "\\set StaffGroup.instrumentName = #\"" + track.getName() + "\"");
   }
   if (this.settings.isScoreEnabled()) {
     this.writer.println(indent(1) + "\\" + id + "Staff");
   }
   if (this.settings.isTablatureEnabled()) {
     this.writer.println(indent(1) + "\\" + id + "TabStaff");
   }
   this.writer.println(">>");
 }
  private void writeTrack(TGTrack track) {
    // header
    int header = 0;
    if (!track.getLyrics().isEmpty()) {
      header |= TRACK_LYRICS;
    }
    writeHeader(header);

    // escribo el nombre
    writeUnsignedByteString(track.getName());

    // escribo el canal
    writeChannel(track);

    // escribo los compases
    TGMeasure lastMeasure = null;
    for (TGMeasure measure : track.getMeasures()) {
      writeMeasure(measure, lastMeasure);
      lastMeasure = measure;
    }

    // escribo la cantidad de cuerdas
    writeByte(track.getStrings().size());

    // escribo las cuerdas
    for (TGString string : track.getStrings()) {
      writeInstrumentString(string);
    }

    // escribo el offset
    writeByte(track.getOffset() - TGTrack.MIN_OFFSET);

    // escribo el color
    writeRGBColor(track.getColor());

    // escribo el lyrics
    if (((header & TRACK_LYRICS) != 0)) {
      writeLyrics(track.getLyrics());
    }
  }