Ejemplo n.º 1
0
  private void write(TGSong song) {
    // escribo el nombre
    writeUnsignedByteString(song.getName());

    // escribo el artista
    writeUnsignedByteString(song.getArtist());

    // escribo el album
    writeUnsignedByteString(song.getAlbum());

    // escribo el autor
    writeUnsignedByteString(song.getAuthor());

    // escribo la cantidad de measure headers
    writeShort((short) song.countMeasureHeaders());

    // escribo las pistas
    TGMeasureHeader lastHeader = null;
    for (TGMeasureHeader header : song.getMeasureHeaders()) {
      writeMeasureHeader(header, lastHeader);
      lastHeader = header;
    }

    // escribo la cantidad de pistas
    writeByte(song.countTracks());

    // escribo las pistas
    for (int i = 0; i < song.countTracks(); i++) {
      TGTrack track = song.getTrack(i);
      writeTrack(track);
    }
  }
Ejemplo n.º 2
0
  private int parseRepeatAlternative(TGSong song, int measure, int value) {
    int repeatAlternative = 0;
    int existentAlternatives = 0;
    Iterator it = song.getMeasureHeaders();
    while (it.hasNext()) {
      TGMeasureHeader header = (TGMeasureHeader) it.next();
      if (header.getNumber() == measure) {
        break;
      }
      if (header.isRepeatOpen()) {
        existentAlternatives = 0;
      }
      existentAlternatives |= header.getRepeatAlternative();
    }

    for (int i = 0; i < 8; i++) {
      if (value > i && (existentAlternatives & (1 << i)) == 0) {
        repeatAlternative |= (1 << i);
      }
    }
    return repeatAlternative;
  }