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;
 }
Beispiel #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 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;
  }
  protected int execute(TypedEvent e) {
    Caret caret = getEditor().getTablature().getCaret();
    if (caret.getSelectedNote() != null) {
      // comienza el undoable
      UndoableMeasureGeneric undoable = UndoableMeasureGeneric.startUndo();

      getSongManager().getMeasureManager().changeTieNote(caret.getSelectedNote());

      // termia el undoable
      addUndoableEdit(undoable.endUndo());
    } else {
      TGNote note = getSongManager().getFactory().newNote();
      note.setValue(0);
      note.setVelocity(caret.getVelocity());
      note.setString(caret.getSelectedString().getNumber());
      note.setTiedNote(true);

      TGDuration duration = getSongManager().getFactory().newDuration();
      caret.getDuration().copy(duration);

      setTiedNoteValue(note, caret);

      // comienza el undoable
      UndoableMeasureGeneric undoable = UndoableMeasureGeneric.startUndo();

      getSongManager()
          .getMeasureManager()
          .addNote(caret.getSelectedBeat(), note, duration, caret.getVoice());

      // termia el undoable
      addUndoableEdit(undoable.endUndo());
    }
    TuxGuitar.instance().getFileHistory().setUnsavedFile();
    updateTablature();
    return 0;
  }