File Coverage

blib/lib/MIDI/XML/Channel.pm
Criterion Covered Total %
statement 11 22 50.0
branch 0 4 0.0
condition n/a
subroutine 4 6 66.6
pod 2 2 100.0
total 17 34 50.0


line stmt bran cond sub pod time code
1             package MIDI::XML::Channel;
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         25  
6              
7 1     1   320 use MIDI::XML::Message;
  1         2  
  1         147  
8              
9             our @ISA = qw(MIDI::XML::Message);
10              
11             =head1 NAME
12              
13             MIDI::XML::Channel - Base class for deriving classes for MIDI channel events.
14              
15             =head1 SYNOPSIS
16              
17             use MIDI::XML::Channel;
18             MIDI::XML::Channel->as_MidiXML($self);
19              
20             =head1 DESCRIPTION
21              
22             MIDI::XML::Channel is the base class from which MIDI Channel objects are
23             derived.
24              
25             =head2 EXPORT
26              
27             None.
28              
29             =cut
30              
31             our $VERSION = '0.01';
32              
33             =head1 METHODS AND ATTRIBUTES
34              
35             =over 4
36              
37             =item $delta_time = $Obj->delta() or $Obj->delta($delta_time);
38              
39             Returns the message time as a delta time or undef if it is an absolute
40             time. Optionally sets the message time to the specified delta time. To
41             avoid contradictory times, the absolute time is set to undef when a delta time
42             is set.
43              
44             This functionality is provided by the MIDI::XML::Message base class.
45              
46             =item $absolute_time = $Obj->absolute() or $Obj->absolute($absolute_time);
47              
48             Returns the message time as an absolute time or undef if it is a delta
49             time. Optionally sets the message time to the specified absolute time. To
50             avoid contradictory times, the delta time is set to undef when an absolute time
51             is set.
52              
53             This functionality is provided by the MIDI::XML::Message base class.
54              
55             =item $time = $Obj->time();
56              
57             Returns the message time, absolute or delta, whichever was last set.
58              
59             This functionality is provided by the MIDI::XML::Message base class.
60              
61             =cut
62              
63             #==========================================================================
64              
65             =item $channel = $Obj->channel() or $Obj->channel($channel);
66              
67             Returns and optionally sets the channel number. Channel numbers are limited
68             to the range 0-15.
69              
70             =cut
71              
72             sub channel {
73 0     0 1   my $self = shift;
74 0 0         if (@_) {
75 0           $self->{'_Channel'} = (shift) & 0x0F;
76             }
77 0           return $self->{'_Channel'};
78             }
79              
80             #==========================================================================
81              
82             =item @xml = $Obj->as_MidiXML();
83              
84             This method is called by the as_MusicXML methods of derived classes.
85              
86             Returns an array of elements formatted according to the MidiXML DTD.
87              
88             =back
89              
90             =cut
91              
92             sub as_MidiXML {
93 0     0 1   my $self = shift;
94 0           my @xml;
95              
96 0           push @xml, MIDI::XML::Message::as_MidiXML($self);
97 0 0         if ( defined($self->{'_Channel'})) {
98 0           my $chn = $self->{'_Channel'}+1;
99 0           $xml[2] = "Channel=\"$chn\"";
100             }
101 0           return @xml;
102             }
103              
104             #==========================================================================
105              
106              
107             return 1;
108             __END__