/** * Reads tremolo bar * * @param NoteEffect $noteEffect */ public function readTremoloBar(NoteEffect $effect) { $tremoloBar = new EffectTremoloBar(); $this->reader->skip(5); $points = $this->reader->readInt(); for ($i = 0; $i < $points; $i++) { $position = $this->reader->readInt(); $value = $this->reader->readInt(); $this->reader->readByte(); $pointPosition = round($position * EffectTremoloBar::MAX_POSITION_LENGTH / GuitarProReaderInterface::GP_BEND_POSITION); $pointValue = round($value / (GuitarProReaderInterface::GP_BEND_SEMITONE * 2)); $tremoloBar->addPoint($pointPosition, $pointValue); } if (count($tremoloBar->getPoints())) { $effect->setTremoloBar($tremoloBar); } }
private function writeTremoloBar(EffectTremoloBar $effect) { $points = count($effect->getPoints()); $this->writeByte(1); $this->writeInt(0); $this->writeInt($points); for ($i = 0; $i < $points; $i++) { $point = $effect->getPoints()[$i]; $this->writeInt($point->getPosition() * GprInterface::GP_BEND_POSITION / EffectBend::MAX_POSITION_LENGTH); $this->writeInt($point->getValue() * GprInterface::GP_BEND_SEMITONE * 2); $this->writeByte(0); } }
/** * Reads tremolo bar * * @param NoteEffect $noteEffect */ public function readTremoloBar(NoteEffect $noteEffect) { $value = $this->reader->readInt(); $effect = new EffectTremoloBar(); $effect->addPoint(0, 0); $effect->addPoint(round(EffectTremoloBar::MAX_POSITION_LENGTH / 2), round(-($value / (GuitarProReaderInterface::GP_BEND_SEMITONE * 2)))); $effect->addPoint(EffectTremoloBar::MAX_POSITION_LENGTH, 0); $noteEffect->setTremoloBar($effect); }