Esempio n. 1
0
  private void writeBendEffect(TGEffectBend effect) {
    // escribo la cantidad de puntos
    writeByte(effect.getPoints().size());

    for (TGEffectBend.BendPoint point : effect.getPoints()) {
      // escribo la posicion
      writeByte(point.getPosition());

      // escribo el valor
      writeByte(point.getValue());
    }
  }
  private void readBend(TGNoteEffect effect) throws IOException {
    TGEffectBend bend = getFactory().newEffectBend();
    skip(5);
    int points = readInt();
    for (int i = 0; i < points; i++) {
      int position = readInt();
      int value = readInt();
      readByte();

      int pointPosition =
          Math.round(position * TGEffectBend.MAX_POSITION_LENGTH / GP_BEND_POSITION);
      int pointValue = Math.round(value * TGEffectBend.SEMITONE_LENGTH / GP_BEND_SEMITONE);
      bend.addPoint(pointPosition, pointValue);
    }
    if (!bend.getPoints().isEmpty()) {
      effect.setBend(bend);
    }
  }