line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MIDI::XML::SequencerSpecific; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
12
|
use 5.006; |
|
1
|
|
|
|
|
2
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
5
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use MIDI::XML::Message; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
518
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(MIDI::XML::Message); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
MIDI::XML::SequencerSpecific - MIDI Sequencer Specific messages. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use MIDI::XML::SequencerSpecific; |
18
|
|
|
|
|
|
|
$Seq_Specific = MIDI::XML::SequencerSpecific->new(); |
19
|
|
|
|
|
|
|
$Seq_Specific->delta(0); |
20
|
|
|
|
|
|
|
$Seq_Specific->data(pack('C*',0,0,119,14,0))); |
21
|
|
|
|
|
|
|
@event = $Seq_Specific->as_event(); |
22
|
|
|
|
|
|
|
$midi_track = MIDI::Track->new(); |
23
|
|
|
|
|
|
|
push( @{$midi_track->events_r},\@event; |
24
|
|
|
|
|
|
|
@xml = $Seq_Specific->as_MidiXML(); |
25
|
|
|
|
|
|
|
print join("\n",@xml); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
MIDI::XML::SequencerSpecific is a class encapsulating MIDI Sequencer Specific |
30
|
|
|
|
|
|
|
meta messages. A Sequencer Specific message includes either a delta time |
31
|
|
|
|
|
|
|
or absolute time as implemented by MIDI::XML::Message and the MIDI |
32
|
|
|
|
|
|
|
Sequencer Specific event encoded in as follows: |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
0xFF 0x7F 0x02 length data |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 EXPORT |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
None. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#========================================================================== |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS AND ATTRIBUTES |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over 4 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item $Seq_Specific = MIDI::XML::SequencerSpecific->new() |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This creates a new MIDI::XML::SequencerSpecific object. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item $Seq_Specific = MIDI::XML::SequencerSpecific->new($event); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Creates a new SequencerSpecific object initialized with the values of a |
57
|
|
|
|
|
|
|
MIDI::Event sequencer_specific array. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub new { |
62
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
63
|
0
|
|
0
|
|
|
|
$class = ref($class) || $class; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $self = { |
66
|
|
|
|
|
|
|
'_Delta'=> undef, |
67
|
|
|
|
|
|
|
'_Absolute'=> undef, |
68
|
|
|
|
|
|
|
'_Data'=> undef, |
69
|
|
|
|
|
|
|
}; |
70
|
0
|
0
|
|
|
|
|
if (@_) { |
71
|
0
|
0
|
|
|
|
|
if (ref($_[0]) eq 'ARRAY') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if ($_[0][0] eq 'sequencer_specific') { |
73
|
0
|
|
|
|
|
|
$self->{'_Delta'} = $_[0][1]; |
74
|
0
|
|
|
|
|
|
$self->{'_Data'} = $_[0][2]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} elsif (ref($_[0]) eq 'HASH') { |
77
|
0
|
|
|
|
|
|
foreach my $attr (keys %{$_[0]}) { |
|
0
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
$self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/); |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
|
my @hex_bytes = split (' ',$_[0]->{'_CDATA'}); |
81
|
0
|
|
|
|
|
|
foreach $b (@hex_bytes) { |
82
|
0
|
|
|
|
|
|
$self->{'_Data'} .= pack('C',hex($b)); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} elsif (ref($_[0]) eq '') { |
85
|
0
|
0
|
|
|
|
|
if ($_[0] eq 'sequencer_specific') { |
86
|
0
|
|
|
|
|
|
$self->{'_Delta'} = $_[1]; |
87
|
0
|
|
|
|
|
|
$self->{'_Data'} = $_[2]; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
bless($self,$class); |
93
|
0
|
|
|
|
|
|
return $self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item $delta_time = $Seq_Specific->delta() or $Seq_Specific->delta($delta_time); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns the message time as a delta time or undef if it is an absolute |
99
|
|
|
|
|
|
|
time. Optionally sets the message time to the specified delta time. To |
100
|
|
|
|
|
|
|
avoid contradictory times, the absolute time is set to undef when a delta time |
101
|
|
|
|
|
|
|
is set. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This functionality is provided by the MIDI::XML::Message base class. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item $absolute_time = $Seq_Specific->absolute() or $Seq_Specific->absolute($absolute_time); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the message time as an absolute time or undef if it is a delta |
108
|
|
|
|
|
|
|
time. Optionally sets the message time to the specified absolute time. To |
109
|
|
|
|
|
|
|
avoid contradictory times, the delta time is set to undef when an absolute time |
110
|
|
|
|
|
|
|
is set. The absolute time should be zero according to the specification. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This functionality is provided by the MIDI::XML::Message base class. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item $time = $Seq_Specific->time(); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns the message time, absolute or delta, whichever was last set. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This functionality is provided by the MIDI::XML::Message base class. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#========================================================================== |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item @data = $Seq_Specific->data(); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub data { |
129
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
130
|
0
|
0
|
|
|
|
|
if (@_) { |
131
|
0
|
|
|
|
|
|
$self->{'_Data'} = shift; |
132
|
|
|
|
|
|
|
} |
133
|
0
|
|
|
|
|
|
return $self->{'_Data'}; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
#========================================================================== |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item $ordinal = $Seq_Specific->ordinal(); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Returns a value to be used to order events that occur at the same time. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub ordinal { |
145
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
146
|
0
|
|
|
|
|
|
return 0x007F; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#========================================================================== |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item @event = $Seq_Specific->as_event(); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Returns a MIDI::Event sequencer_specific array initialized with the values |
154
|
|
|
|
|
|
|
of the Sequencer Specific object. MIDI::Event does not expect absolute times |
155
|
|
|
|
|
|
|
and will interpret them as delta times. Calling this method when the time |
156
|
|
|
|
|
|
|
is absolute will not generate a warning or error but it is unlikely that |
157
|
|
|
|
|
|
|
the results will be satisfactory. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub as_event { |
162
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my @event = ( |
165
|
|
|
|
|
|
|
'sequencer_specific', |
166
|
|
|
|
|
|
|
MIDI::XML::Message::time($self), |
167
|
0
|
|
|
|
|
|
$self->{'_Data'} |
168
|
|
|
|
|
|
|
); |
169
|
0
|
|
|
|
|
|
return @event; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
#========================================================================== |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item @xml = $Seq_Specific->as_MidiXML(); |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Returns an array of elements formatted according to the MidiXML DTD. These |
177
|
|
|
|
|
|
|
elements may be assembled by track into entire documents with the following |
178
|
|
|
|
|
|
|
suggested DOCTYPE declaration: |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
"-//Recordare//DTD MusicXML 0.7 MIDI//EN" |
182
|
|
|
|
|
|
|
"http://www.musicxml.org/dtds/midixml.dtd"> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=back |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub as_MidiXML { |
189
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
190
|
0
|
|
|
|
|
|
my @xml; |
191
|
|
|
|
|
|
|
my @bytes; |
192
|
|
|
|
|
|
|
# print "@{$self->{'_Data'}}\n"; |
193
|
0
|
0
|
|
|
|
|
if ( defined($self->{'_Data'})) { |
194
|
0
|
|
|
|
|
|
for (my $i=0; $i{'_Data'}); $i++) { |
195
|
0
|
|
|
|
|
|
push @bytes, sprintf("%02X",ord(substr($self->{'_Data'},$i,1))); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
# @bytes = @{$self->{'_Data'}}; |
199
|
0
|
|
|
|
|
|
push @xml, MIDI::XML::Message::as_MidiXML($self); |
200
|
0
|
|
|
|
|
|
$xml[2] = "@bytes"; |
201
|
0
|
|
|
|
|
|
return @xml; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
#========================================================================== |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
return 1; |
208
|
|
|
|
|
|
|
__END__ |