public function __clone() { $effect = new EffectTremoloBar(); foreach ($this->points as $point) { $effect->addPoint($point->getPosition(), $point->getValue()); } return $effect; }
public function makeTremoloBar(MidiSequenceHelper $sHelper, $track, $start, $duration, EffectTremoloBar $effect, $channel, $midiVoice, $bendMode) { $points = $effect->getPoints(); for ($i = 0; $i < count($points); $i++) { $point = $points[$i]; $pointStart = $start + $point->getTime($duration); $value = self::DEFAULT_BEND + intval($point->getValue() * self::DEFAULT_BEND_SEMI_TONE * 2); $value = $value <= 127 ? $value : 127; $value = $value >= 0 ? $value : 0; $this->addBend($sHelper, $track, $pointStart, $value, $channel, $bendMode); if (count($points) > $i + 1) { $nextPoint = $points[$i + 1]; $nextValue = self::DEFAULT_BEND + intval($nextPoint->getValue() * self::DEFAULT_BEND_SEMI_TONE * 2); $nextPointStart = $start + $nextPoint->getTime($duration); if ($nextValue != $value) { $width = ($nextPointStart - $pointStart) / abs($nextValue - $value); //asc if ($value < $nextValue) { while ($value < $nextValue) { $value++; $pointStart += $width; $this->addBend($sHelper, $track, $pointStart, $value <= 127 ? $value : 127, $channel, $bendMode); } //desc } else { if ($value > $nextValue) { while ($value > $nextValue) { $value--; $pointStart += $width; $this->addBend($sHelper, $track, $pointStart, $value >= 0 ? $value : 0, $channel, $bendMode); } } } } } } $this->addBend($sHelper, $track, $start + $duration, self::DEFAULT_BEND, $channel, $bendMode); }