コード例 #1
0
 /**
  * Reads Guitar Pro version
  * 
  * @return void
  */
 protected function readVersion()
 {
     if ($this->version == null) {
         $this->version = $this->readStringByte(30, 'UTF-8');
         Log::add($this->version);
     }
 }
コード例 #2
0
ファイル: LogTest.php プロジェクト: stdtabs/phptabs
 public function testLog()
 {
     Log::clear();
     Config::set('verbose', true);
     # Empty log
     $this->assertEquals(0, Log::countLogs());
     $this->assertEquals(array(), Log::tail(4));
     # Adds a default type message
     $this->expectOutputString("\n[NOTICE] Log with default type");
     Log::add('Log with default type');
     $expected = array(0 => array('type' => 'NOTICE', 'message' => 'Log with default type'));
     $this->assertEquals($expected, Log::tail(42));
     $this->assertEquals($expected, Log::tail(1));
     # counts an unexisting key
     $this->assertEquals(0, Log::countLogs(42));
     # Counts an existing key
     $this->assertEquals(1, Log::countLogs('NOTICE'));
     Config::set('verbose', false);
 }
コード例 #3
0
ファイル: MidiReader.php プロジェクト: stdtabs/phptabs
 private function parseMessage($trackNumber, $tick, MidiMessage $message)
 {
     $parsedTick = $this->parseTick($tick + $this->resolution);
     //NOTE ON
     if ($message->getType() == MidiMessage::TYPE_SHORT && $message->getCommand() == MidiMessage::NOTE_ON) {
         $this->parseNoteOn($trackNumber, $parsedTick, $message->getData());
     } else {
         if ($message->getType() == MidiMessage::TYPE_SHORT && $message->getCommand() == MidiMessage::NOTE_OFF) {
             $this->parseNoteOff($trackNumber, $parsedTick, $message->getData());
         } else {
             if ($message->getType() == MidiMessage::TYPE_SHORT && $message->getCommand() == MidiMessage::PROGRAM_CHANGE) {
                 $this->parseProgramChange($message->getData());
             } else {
                 if ($message->getType() == MidiMessage::TYPE_SHORT && $message->getCommand() == MidiMessage::CONTROL_CHANGE) {
                     $this->parseControlChange($message->getData());
                 } else {
                     if ($message->getType() == MidiMessage::TYPE_SHORT && $message->getCommand() == MidiMessage::PITCH_BEND) {
                         $this->parsePitchBend($message->getData());
                     } else {
                         if ($message->getType() == MidiMessage::TYPE_META && $message->getCommand() == MidiMessage::TIME_SIGNATURE_CHANGE) {
                             $this->parseTimeSignature($parsedTick, $message->getData());
                         } else {
                             if ($message->getType() == MidiMessage::TYPE_META && $message->getCommand() == MidiMessage::TEMPO_CHANGE) {
                                 $this->parseTempo($parsedTick, $message->getData());
                             } else {
                                 $logMessage = sprintf('track=%d, tick=%d, type=%s, command=%x, data=array(%s)', $trackNumber, $tick, $message->getType(), $message->getCommand(), implode(', ', $message->getData()));
                                 Log::add($logMessage, 'MIDI_SKIPPED_MESSAGE');
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: File.php プロジェクト: stdtabs/phptabs
 /**
  * Streams a binary file
  * 
  * @param int $bytes
  * @param int $offset
  * @param int $length
  * 
  * @return string a file segment
  * 
  * @throws Exception If asked position is larger than the file size
  */
 public function getStream($bytes = 1, $offset = null)
 {
     if (!$this->handle) {
         $this->handle = fopen($this->getPath(), "rb");
     } else {
         if (feof($this->handle)) {
             return;
         } else {
             if ($this->getStreamPosition() + $bytes > $this->getSize()) {
                 throw new Exception('Pointer');
             }
         }
     }
     $message = __METHOD__ . "({$bytes}): position:" . $this->getStreamPosition();
     # Nothing to read
     if ($bytes <= 0) {
         Log::add($message, 'NOTICE');
         return;
     }
     # Read $bytes with no offset
     if (null === $offset) {
         $this->stream = fread($this->handle, $bytes);
         Log::add($message . '|stream=' . $this->stream, 'NOTICE');
         return $this->stream;
     }
     Log::add($message, 'NOTICE');
     # Moves pointer to $offset
     fread($this->handle, $offset);
     return $this->getStream($bytes);
 }