private TGNote readNote(TGString string, TGTrack track, TGNoteEffect effect) throws IOException {
   int flags = readUnsignedByte();
   TGNote note = getFactory().newNote();
   note.setString(string.getNumber());
   note.setEffect(effect);
   note.getEffect().setAccentuatedNote(((flags & 0x40) != 0));
   note.getEffect().setGhostNote(((flags & 0x04) != 0));
   if ((flags & 0x20) != 0) {
     int noteType = readUnsignedByte();
     note.setTiedNote((noteType == 0x02));
     note.getEffect().setDeadNote((noteType == 0x03));
   }
   if ((flags & 0x01) != 0) {
     skip(2);
   }
   if ((flags & 0x10) != 0) {
     note.setVelocity(
         (TGVelocities.MIN_VELOCITY + (TGVelocities.VELOCITY_INCREMENT * readByte()))
             - TGVelocities.VELOCITY_INCREMENT);
   }
   if ((flags & 0x20) != 0) {
     int fret = readByte();
     int value = (note.isTiedNote() ? getTiedNoteValue(string.getNumber(), track) : fret);
     note.setValue(value >= 0 && value < 100 ? value : 0);
   }
   if ((flags & 0x80) != 0) {
     skip(2);
   }
   if ((flags & 0x08) != 0) {
     readNoteEffects(note.getEffect());
   }
   return note;
 }
Exemple #2
0
  private void readNote(int header, TGVoice voice, TGBeatData data) {
    TGNote note = this.factory.newNote();

    // leo el valor
    note.setValue(readByte());

    // leo la cuerda
    note.setString(readByte());

    // leo la ligadura
    note.setTiedNote((header & NOTE_TIED) != 0);

    // leo el velocity
    if (((header & NOTE_VELOCITY) != 0)) {
      data.getVoice(voice.getIndex()).setVelocity(readByte());
    }
    note.setVelocity(data.getVoice(voice.getIndex()).getVelocity());

    // leo los efectos
    if (((header & NOTE_EFFECT) != 0)) {
      readNoteEffect(note.getEffect());
    }

    voice.addNote(note);
  }
  private void writeNote(int header, TGNote note) {
    // escribo el valor
    writeByte(note.getValue());

    // escribo la cuerda
    writeByte(note.getString());

    // escribo el velocity
    if (((header & NOTE_VELOCITY) != 0)) {
      writeByte(note.getVelocity());
    }

    // escribo los efectos
    if (((header & NOTE_EFFECT) != 0)) {
      writeNoteEffect(note.getEffect());
    }
  }
  private void writeNotes(TGVoice voice, TGBeatData data) {
    for (int i = 0; i < voice.countNotes(); i++) {
      TGNote note = voice.getNote(i);

      int header = (i + 1 < voice.countNotes() ? NOTE_HAS_NEXT : 0);
      header = (note.isTiedNote()) ? header |= NOTE_TIED : header;
      if (note.getVelocity() != data.getVelocity()) {
        data.setVelocity(note.getVelocity());
        header |= NOTE_VELOCITY;
      }
      header = (note.getEffect().hasAnyEffect()) ? header |= NOTE_EFFECT : header;

      writeHeader(header);

      writeNote(header, note);
    }
  }
  private TGBeat readNote(TGMeasure measure, TGBeat previous) {
    TGBeat beat = previous;

    // leo el valor
    int value = readInt();

    // leo el start
    long start = (TGDuration.QUARTER_TIME * readLong() / 1000);
    if (beat == null || beat.getStart() != start) {
      beat = this.factory.newBeat();
      beat.setStart(start);
      measure.addBeat(beat);
    }
    TGVoice voice = beat.getVoice(0);
    voice.setEmpty(false);

    // leo la duracion
    readDuration(voice.getDuration());

    TGNote note = this.factory.newNote();

    note.setValue(value);

    // leo el velocity
    note.setVelocity(readInt());

    // leo la cuerda
    note.setString(readInt());

    // leo la ligadura
    note.setTiedNote(readBoolean());

    // leo los efectos
    readNoteEffect(note.getEffect());

    voice.addNote(note);
    return beat;
  }