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