Example #1
0
 /**
  * Gets the binary representation of this meta event
  *
  * @since 1.0
  * @uses  Util::pack()
  * @uses  Util::getDeltaByteSequence()
  * @uses  getSubtype()
  * 
  * @return binary
  */
 public function toBinary()
 {
     if (is_array($this->data)) {
         $data = '';
         foreach ($this->data as $datum) {
             $data .= Util::pack($datum);
         }
     } else {
         $data = $this->data;
     }
     return Util::pack($this->getType(), $this->getSubtype()) . Util::getDeltaByteSequence($this->length) . $data;
 }
Example #2
0
 /**
  * Gets a binary representation of this event
  *
  * @since 1.0
  * @uses  Util::pack()
  * 
  * @return binary
  */
 public function toBinary()
 {
     $binary = $this->isContinuation() ? '' : Util::pack($this->getType() | $this->channel);
     $binary .= Util::pack($this->param1, $this->param2);
     return $binary;
 }
 /**
  * Gets whether this is a normal system exclusive event
  *
  * Normal sysex events are signified by the last byte of data
  * being 0xF7.
  *
  * @since 1.0
  * @uses  Util::pack()
  * @see   isDivided()
  * 
  * @return bool
  */
 public function isNormal()
 {
     $byte = end($this->data);
     reset($this->data);
     return $byte === Util::pack(0xf7);
 }
Example #4
0
 public function testPackWithNullValues()
 {
     $this->assertSame(pack('C2', 0x30, 0x20), Util::pack(0x30, 0x20, null));
 }
Example #5
0
 /**
  * @since 1.0
  * @uses  Util::pack()
  * 
  * @return binary
  */
 public function toBinary()
 {
     return Util::pack(0x4d, 0x54, 0x68, 0x64) . Util::pack(0x0, 0x0, 0x0, 0x6) . Util::pack(0x0, $this->midiFormat) . Util::pack($this->numTracks >> 8, $this->numTracks & 0xff) . Util::pack($this->timeDivision >> 8, $this->timeDivision & 0xff);
 }
 public function testToBinary()
 {
     $binary = Util::pack(EventType::SYSTEM_EXCLUSIVE) . Util::getDeltaByteSequence(255) . str_repeat('x', 255);
     $this->assertEquals($binary, $this->obj->toBinary());
 }