public function write(MidiSequence $sequence, $type) { $this->writeInt(MidiReaderInterface::HEADER_MAGIC); $this->writeInt(MidiReaderInterface::HEADER_LENGTH); $this->writeShort($type); # Write sequences $this->writeShort($sequence->countTracks()); $this->writeShort($sequence->getDivisionType() == MidiSequence::PPQ ? $sequence->getResolution() & 0x7fff : 0); for ($i = 0; $i < $sequence->countTracks(); $i++) { $this->writeTrack($sequence->getTrack($i)); } }
private function initFields(MidiSequence $sequence) { $this->resolution = $sequence->getResolution(); $this->channels = array(); $this->headers = array(); $this->tracks = array(); $this->tempNotes = array(); $this->tempChannels = array(); $this->trackTuningHelpers = array(); $this->channelRouter = new ChannelRouter(); }