private function makeChannels(Song $song) { $channels = array(); for ($i = 0; $i < 64; $i++) { $channels[$i] = new Channel(); $channels[$i]->setProgram($i == Channel::DEFAULT_PERCUSSION_CHANNEL ? Channel::DEFAULT_PERCUSSION_PROGRAM : 24); $channels[$i]->setVolume(13); $channels[$i]->setBalance(8); $channels[$i]->setChorus(0); $channels[$i]->setReverb(0); $channels[$i]->setPhaser(0); $channels[$i]->setTremolo(0); } $songChannels = $song->getChannels(); foreach ($songChannels as $channel) { $channelRoute = $this->getChannelRoute($channel->getChannelId()); $channels[$channelRoute->getChannel1()]->setProgram($channel->getProgram()); $channels[$channelRoute->getChannel1()]->setVolume($channel->getVolume()); $channels[$channelRoute->getChannel1()]->setBalance($channel->getBalance()); $channels[$channelRoute->getChannel2()]->setProgram($channel->getProgram()); $channels[$channelRoute->getChannel2()]->setVolume($channel->getVolume()); $channels[$channelRoute->getChannel2()]->setBalance($channel->getBalance()); } return $channels; }
protected function isPercussionChannel(Song $song, $channelId) { $channels = $song->getChannels(); foreach ($channels as $channel) { if ($channel->getChannelId() == $channelId) { return $channel->isPercussionChannel(); } } return false; }
public function __construct(Song $song) { parent::__construct(); # Build sequence $channelRouter = new ChannelRouter(); $channelRouterConfigurator = new ChannelRouterConfigurator($channelRouter); $channelRouterConfigurator->configureRouter($song->getChannels()); $settings = (new MidiSettings())->getdefaults(); $midiSequenceParser = new MidiSequenceParser($song, self::ADD_FIRST_TICK_MOVE | self::ADD_DEFAULT_CONTROLS | self::ADD_MIXER_MESSAGES); $midiSequenceParser->setTranspose($settings->getTranspose()); $midiSequenceParser->parse(new MidiSequenceHandler($song->countTracks() + 1, $channelRouter, $this)); }
public function addDefaultMessages(MidiSequenceHelper $sHelper, Song $song) { if (($this->flags & MidiWriter::ADD_DEFAULT_CONTROLS) != 0) { $channels = $song->getChannels(); foreach ($channels as $channel) { $channelId = $channel->getChannelId(); $sHelper->getSequence()->addControlChange($this->getTick(Duration::QUARTER_TIME), $this->getInfoTrack(), $channelId, MidiWriter::RPN_MSB, 0); $sHelper->getSequence()->addControlChange($this->getTick(Duration::QUARTER_TIME), $this->getInfoTrack(), $channelId, MidiWriter::RPN_LSB, 0); $sHelper->getSequence()->addControlChange($this->getTick(Duration::QUARTER_TIME), $this->getInfoTrack(), $channelId, MidiWriter::DATA_ENTRY_MSB, 12); $sHelper->getSequence()->addControlChange($this->getTick(Duration::QUARTER_TIME), $this->getInfoTrack(), $channelId, MidiWriter::DATA_ENTRY_LSB, 0); } } }
protected function configureChannelRouter(Song $song) { $this->channelRouter = new ChannelRouter(); $routerConfigurator = new ChannelRouterConfigurator($this->channelRouter); $routerConfigurator->configureRouter($song->getChannels()); }
/** * Checks if a channel is still defined * * @param Song $song * @param string $name * @return boolean Result of the search */ protected function findChannelsByName(Song $song, $name) { $channels = $song->getChannels(); foreach ($channels as $v) { if ($v->getName() == $name) { return true; } } return false; }