/** * Reads bend * * @param NoteEffect $effect */ public function readBend(NoteEffect $effect) { $bend = new EffectBend(); $this->reader->skip(5); $points = $this->reader->readInt(); for ($i = 0; $i < $points; $i++) { $bendPosition = $this->reader->readInt(); $bendValue = $this->reader->readInt(); $this->reader->readByte(); //vibrato $pointPosition = round($bendPosition * EffectBend::MAX_POSITION_LENGTH / GuitarProReaderInterface::GP_BEND_POSITION); $pointValue = round($bendValue * EffectBend::SEMITONE_LENGTH / GuitarProReaderInterface::GP_BEND_SEMITONE); $bend->addPoint($pointPosition, $pointValue); } if (count($bend->getPoints())) { $effect->setBend($bend); } }
private function makeNoteEffect(Note $note, array $pitchBends) { $tmp = array(); foreach ($pitchBends as $pitchBend) { if (!in_array($pitchBend, $tmp)) { array_push($tmp, $pitchBend); } } // All pitches have the same value: vibrato if (count($tmp) == 1) { $note->getEffect()->setVibrato(true); return; } // Bend $bend = new EffectBend(); $bend->addPoint(0, 0); foreach ($pitchBends as $k => $pitchBend) { $bend->addPoint($k, $pitchBend); } $note->getEffect()->setBend($bend); }