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