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