Esempio n. 1
0
  private long readBeat(long start, TGMeasure measure, TGTrack track, TGTempo tempo, int voiceIndex)
      throws IOException {
    int flags = readUnsignedByte();

    TGBeat beat = getBeat(measure, start);
    TGVoice voice = beat.getVoice(voiceIndex);
    if ((flags & 0x40) != 0) {
      int beatType = readUnsignedByte();
      voice.setEmpty((beatType & 0x02) == 0);
    }
    TGDuration duration = readDuration(flags);
    TGNoteEffect effect = new TGNoteEffect();
    if ((flags & 0x02) != 0) {
      readChord(track.stringCount(), beat);
    }
    if ((flags & 0x04) != 0) {
      readText(beat);
    }
    if ((flags & 0x08) != 0) {
      readBeatEffects(beat, effect);
    }
    if ((flags & 0x10) != 0) {
      readMixChange(tempo);
    }
    int stringFlags = readUnsignedByte();
    for (int i = 6; i >= 0; i--) {
      if ((stringFlags & (1 << i)) != 0 && (6 - i) < track.stringCount()) {
        TGString string = track.getString((6 - i) + 1).clone();
        TGNote note = readNote(string, track, effect.clone());
        voice.addNote(note);
      }
      voice.setDuration(duration.clone());
    }

    skip(1);

    int read = readByte();
    // if (read == 8 || read == 10 || read == 24 ) {
    if ((read & 0x08) != 0) {
      skip(1);
    }

    return (!voice.isEmpty() ? duration.getTime() : 0);
  }
  private long readBeat(long start, TGMeasure measure, TGTrack track, TGTempo tempo)
      throws IOException {
    int flags = readUnsignedByte();
    if ((flags & 0x40) != 0) {
      readUnsignedByte();
    }

    TGBeat beat = getFactory().newBeat();
    TGVoice voice = beat.getVoice(0);
    TGDuration duration = readDuration(flags);
    TGNoteEffect effect = getFactory().newEffect();
    if ((flags & 0x02) != 0) {
      readChord(track.stringCount(), beat);
    }
    if ((flags & 0x04) != 0) {
      readText(beat);
    }
    if ((flags & 0x08) != 0) {
      readBeatEffects(beat, effect);
    }
    if ((flags & 0x10) != 0) {
      readMixChange(tempo);
    }
    int stringFlags = readUnsignedByte();
    for (int i = 6; i >= 0; i--) {
      if ((stringFlags & (1 << i)) != 0 && (6 - i) < track.stringCount()) {
        TGString string = track.getString((6 - i) + 1).clone(getFactory());
        TGNote note = readNote(string, track, effect.clone(getFactory()));
        voice.addNote(note);
      }
    }
    beat.setStart(start);
    voice.setEmpty(false);
    duration.copy(voice.getDuration());
    measure.addBeat(beat);

    return duration.getTime();
  }