Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 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);
  }
Ejemplo n.º 3
0
  private boolean addNote(TGBeat beat, long start, int value) {
    if (beat != null) {
      TGMeasure measure = getMeasure();
      Caret caret = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret();

      List strings = measure.getTrack().getStrings();
      for (int i = 0; i < strings.size(); i++) {
        TGString string = (TGString) strings.get(i);
        if (value >= string.getValue()) {
          boolean emptyString = true;

          for (int v = 0; v < beat.countVoices(); v++) {
            TGVoice voice = beat.getVoice(v);
            Iterator it = voice.getNotes().iterator();
            while (it.hasNext()) {
              TGNoteImpl note = (TGNoteImpl) it.next();
              if (note.getString() == string.getNumber()) {
                emptyString = false;
                break;
              }
            }
          }
          if (emptyString) {
            TGSongManager manager = TuxGuitar.instance().getSongManager();

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

            TGNote note = manager.getFactory().newNote();
            note.setValue((value - string.getValue()));
            note.setVelocity(caret.getVelocity());
            note.setString(string.getNumber());

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

            manager.getMeasureManager().addNote(beat, note, duration, start, caret.getVoice());

            caret.moveTo(
                caret.getTrack(), caret.getMeasure(), note.getVoice().getBeat(), note.getString());

            // termia el undoable
            TuxGuitar.instance().getUndoableManager().addEdit(undoable.endUndo());
            TuxGuitar.instance().getFileHistory().setUnsavedFile();

            // reprodusco las notas en el pulso
            TuxGuitar.instance().playBeat(caret.getSelectedBeat());

            this.afterAction();

            return true;
          }
        }
      }
    }
    return false;
  }
Ejemplo n.º 4
0
  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;
  }