示例#1
0
 /**
  * Creates a channel name with a program
  * 
  * @param Song $song
  * @param Channel $channel
  * @return string a new channel name
  */
 protected function createChannelNameFromProgram(Song $song, $channel)
 {
     $names = ChannelNames::$defaultNames;
     if ($channel->getProgram() >= 0 && isset($names[$channel->getProgram()])) {
         return $this->createChannelName($song, $names[$channel->getProgram()]);
     }
     return $this->createDefaultChannelName($song);
 }
示例#2
0
 private function getRealVelocity(MidiSequenceHelper $sHelper, Note $note, Track $track, Channel $channel, $mIndex, $bIndex)
 {
     $velocity = $note->getVelocity();
     //Check for Hammer effect
     if (!$channel->isPercussionChannel()) {
         $previousNote = $this->getPreviousNote($sHelper, $note, $track, $mIndex, $bIndex, false);
         if ($previousNote !== null && $previousNote->getNote()->getEffect()->isHammer()) {
             $velocity = max(Velocities::MIN_VELOCITY, $velocity - 25);
         }
     }
     //Check for GhostNote effect
     if ($note->getEffect()->isGhostNote()) {
         $velocity = max(Velocities::MIN_VELOCITY, $velocity - Velocities::VELOCITY_INCREMENT);
     } else {
         if ($note->getEffect()->isAccentuatedNote()) {
             $velocity = max(Velocities::MIN_VELOCITY, $velocity + Velocities::VELOCITY_INCREMENT);
         } else {
             if ($note->getEffect()->isHeavyAccentuatedNote()) {
                 $velocity = max(Velocities::MIN_VELOCITY, $velocity + Velocities::VELOCITY_INCREMENT * 2);
             }
         }
     }
     return $velocity > 127 ? 127 : $velocity;
 }
示例#3
0
 private function checkChannels()
 {
     for ($tc = 0; $tc < count($this->tempChannels); $tc++) {
         $tempChannel = $this->tempChannels[$tc];
         if ($tempChannel->getTrack() > 0) {
             $channelExists = false;
             for ($c = 0; $c < count($this->channels); $c++) {
                 $channel = $this->channels[$c];
                 $channelRoute = $this->channelRouter->getRoute($channel->getChannelId());
                 if ($channelRoute !== null) {
                     if ($channelRoute->getChannel1() == $tempChannel->getChannel() || $channelRoute->getChannel2() == $tempChannel->getChannel()) {
                         $channelExists = true;
                     }
                 }
             }
             if (!$channelExists) {
                 $channel = new Channel();
                 $channel->setChannelId(count($this->channels) + 1);
                 $channel->setProgram($tempChannel->getInstrument());
                 $channel->setVolume($tempChannel->getVolume());
                 $channel->setBalance($tempChannel->getBalance());
                 $channel->setName('#' . $channel->getChannelId());
                 $channel->setBank($tempChannel->getChannel() == 9 ? Channel::DEFAULT_PERCUSSION_BANK : Channel::DEFAULT_BANK);
                 $channelRoute = new ChannelRoute($channel->getChannelId());
                 $channelRoute->setChannel1($tempChannel->getChannel());
                 $channelRoute->setChannel2($tempChannel->getChannel());
                 for ($tcAux = $tc + 1; $tcAux < count($this->tempChannels); $tcAux++) {
                     $tempChannelAux = $this->tempChannels[$tcAux];
                     if ($tempChannel->getTrack() == $tempChannelAux->getTrack()) {
                         if ($channelRoute->getChannel2() == $channelRoute->getChannel1()) {
                             $channelRoute->setChannel2($tempChannelAux->getChannel());
                         } else {
                             $tempChannelAux->setTrack(-1);
                         }
                     }
                 }
                 $this->channelRouter->configureRoutes($channelRoute, $tempChannel->getChannel() == 9);
                 $this->channels[] = $channel;
             }
         }
     }
 }
示例#4
0
 /**
  * Reads channels informations
  * 
  * @return array $channels
  */
 public function readChannels()
 {
     $channels = array();
     for ($i = 0; $i < 64; $i++) {
         $channel = new Channel();
         $channel->setProgram($this->reader->readInt());
         $channel->setVolume($this->toChannelShort($this->reader->readByte()));
         $channel->setBalance($this->toChannelShort($this->reader->readByte()));
         $channel->setChorus($this->toChannelShort($this->reader->readByte()));
         $channel->setReverb($this->toChannelShort($this->reader->readByte()));
         $channel->setPhaser($this->toChannelShort($this->reader->readByte()));
         $channel->setTremolo($this->toChannelShort($this->reader->readByte()));
         $channel->setBank($i == 9 ? Channel::DEFAULT_PERCUSSION_BANK : Channel::DEFAULT_BANK);
         if ($channel->getProgram() < 0) {
             $channel->setProgram(0);
         }
         $channels[] = $channel;
         $this->reader->skip(2);
     }
     return $channels;
 }