Exemple #1
0
  private TGTrack readTrack(int number, TGSong song) {
    // header
    int header = readHeader();

    TGTrack track = this.factory.newTrack();

    track.setNumber(number);

    // leo el nombre
    track.setName(readUnsignedByteString());

    // leo el solo
    track.setSolo((header & TRACK_SOLO) != 0);

    // leo el mute
    track.setMute((header & TRACK_MUTE) != 0);

    // leo el canal
    readChannel(song, track);

    // leo la cantidad de compases
    int measureCount = song.countMeasureHeaders();

    // leo los compases
    TGMeasure lastMeasure = null;
    for (int i = 0; i < measureCount; i++) {
      TGMeasure measure = readMeasure(song.getMeasureHeader(i), lastMeasure);
      track.addMeasure(measure);
      lastMeasure = measure;
    }

    // leo la cantidad de cuerdas
    int stringCount = readByte();

    // leo las cuerdas
    for (int i = 0; i < stringCount; i++) {
      track.getStrings().add(readInstrumentString(i + 1));
    }

    // leo el offset
    track.setOffset(TGTrack.MIN_OFFSET + readByte());

    // leo el color
    readRGBColor(track.getColor());

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

    return track;
  }
 private void readMeasures(TGSong song, int measures, int tracks, int tempoValue)
     throws IOException {
   TGTempo tempo = getFactory().newTempo();
   tempo.setValue(tempoValue);
   long start = TGDuration.QUARTER_TIME;
   for (int i = 0; i < measures; i++) {
     TGMeasureHeader header = song.getMeasureHeader(i);
     header.setStart(start);
     for (int j = 0; j < tracks; j++) {
       TGTrack track = song.getTrack(j);
       TGMeasure measure = getFactory().newMeasure(header);
       track.addMeasure(measure);
       readMeasure(measure, track, tempo);
     }
     tempo.copy(header.getTempo());
     start += header.getLength();
   }
 }
  private TGTrack readTrack(TGSong song) {
    TGTrack track = this.factory.newTrack();

    // leo el numero
    track.setNumber((int) readLong());

    // leo el nombre
    track.setName(readString());

    // leo el canal
    readChannel(track);

    // leo la cantidad de compases
    int measureCount = readInt();

    if (song.countMeasureHeaders() == 0) {
      for (int i = 0; i < measureCount; i++) {
        TGMeasureHeader header = this.factory.newHeader();
        song.addMeasureHeader(header);
      }
    }

    // leo los compases
    for (int i = 0; i < measureCount; i++) {
      track.addMeasure(readMeasure(song.getMeasureHeader(i)));
    }

    // leo la cantidad de cuerdas
    int stringCount = readInt();

    // leo las cuerdas
    for (int i = 0; i < stringCount; i++) {
      track.getStrings().add(readInstrumentString());
    }

    // leo el color
    readColor(track.getColor());

    return track;
  }