1 : <?php
2 :
3 : /**
4 : * \Midi\Delta
5 : *
6 : * @package Midi
7 : * @copyright © 2009 Tommy Montgomery <http://phpmidiparser.com>
8 : * @since 1.0
9 : */
10 :
11 : namespace Midi;
12 :
13 : /**
14 : * Represents a variable-length delta time
15 : *
16 : * @package Midi
17 : * @since 1.0
18 : */
19 1 : class Delta implements Chunk {
20 :
21 : /**
22 : * @var int
23 : */
24 : private $ticks;
25 :
26 : /**
27 : * Constructor
28 : *
29 : * @since 1.0
30 : *
31 : * @param int $ticks The number of MIDI clock ticks in this delta event
32 : */
33 : public function __construct($ticks) {
34 7 : $this->ticks = $ticks;
35 7 : }
36 :
37 : /**
38 : * Describe this function
39 : *
40 : * @since 1.0
41 : *
42 : * @return array
43 : */
44 : public function getData() {
45 1 : return array($this->ticks);
46 : }
47 :
48 : /**
49 : * @since 1.0
50 : * @uses Util::getDeltaByteSequence()
51 : *
52 : * @return Util
53 : */
54 : public function toBinary() {
55 2 : return Util\Util::getDeltaByteSequence($this->ticks);
56 : }
57 :
58 : /**
59 : * @since 1.0
60 : *
61 : * @return string
62 : */
63 : public function __toString() {
64 1 : return 'Delta value: ' . $this->ticks;
65 : }
66 :
67 : /**
68 : * @since 1.0
69 : * @uses toBinary()
70 : *
71 : * @return int
72 : */
73 : public function getLength() {
74 1 : return strlen($this->toBinary());
75 : }
76 :
77 : }
78 :
|