| 1 | #! perl | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | package Music::ChordBot::Opus::Section::Chord; | ||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | Music::ChordBot::Opus::Section::Chord - ChordBot chords. | ||||||||||
| 11 | |||||||||||
| 12 | =cut | ||||||||||
| 13 | |||||||||||
| 14 | 6 | our $VERSION = 0.01; | |||||||||
| 15 | |||||||||||
| 16 | 6 | ▶ | use parent 'Music::ChordBot::Opus::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||
| 19 | |||||||||||
| 20 | use Music::ChordBot::Opus::Section::Chord; | ||||||||||
| 21 | $chord = Music::ChordBot::Section::Chord->new; | ||||||||||
| 22 | $chord->root("C"); | ||||||||||
| 23 | $chord->type("Min7"); | ||||||||||
| 24 | $chord->duration(4); | ||||||||||
| 25 | |||||||||||
| 26 | or | ||||||||||
| 27 | |||||||||||
| 28 | $chord = Music::ChordBot::Section::Chord->new("C Min7 4"); | ||||||||||
| 29 | |||||||||||
| 30 | or | ||||||||||
| 31 | |||||||||||
| 32 | $chord = Music::ChordBot::Section::Chord->new("C", "Min7", 4); | ||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | =head1 METHODS | ||||||||||
| 36 | |||||||||||
| 37 | =head2 new [ args ] | ||||||||||
| 38 | |||||||||||
| 39 | Creates a new Music::ChordBot::Opus::Section::Chord object. | ||||||||||
| 40 | |||||||||||
| 41 | The chord key, type and duration may be passed as arguments to the | ||||||||||
| 42 | constructor, either as three separate values, or as a string | ||||||||||
| 43 | containing these values space separated. | ||||||||||
| 44 | |||||||||||
| 45 | Attributes: | ||||||||||
| 46 | |||||||||||
| 47 | =over 4 | ||||||||||
| 48 | |||||||||||
| 49 | =item root | ||||||||||
| 50 | |||||||||||
| 51 | The root (key) of the chord. | ||||||||||
| 52 | |||||||||||
| 53 | =item bass | ||||||||||
| 54 | |||||||||||
| 55 | An added bass note of the chord. | ||||||||||
| 56 | |||||||||||
| 57 | =item type | ||||||||||
| 58 | |||||||||||
| 59 | The type, e.g., "Maj" (major), "Min" (minor), "7" (seventh) and so on. | ||||||||||
| 60 | |||||||||||
| 61 | =item duration | ||||||||||
| 62 | |||||||||||
| 63 | The duration, in beats. | ||||||||||
| 64 | |||||||||||
| 65 | =item inversion | ||||||||||
| 66 | |||||||||||
| 67 | Thee inversion, if applicable. | ||||||||||
| 68 | |||||||||||
| 69 | =cut | ||||||||||
| 70 | |||||||||||
| 71 | 58 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 72 | 58 | my $pkg = shift; | |||||||||
| 73 | 58 | my $data = {}; | |||||||||
| 74 | 58 | ▶ | if ( @_ == 1 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 18 | @_ = split( ' ', $_[0] ); | |||||||||
| 76 | } | ||||||||||
| 77 | 58 | ▶ | if ( @_ == 3 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | 56 | $data->{root} = shift; | |||||||||
| 79 | 56 | ▶ | if ( $data->{root} =~ /^(.+)\/(.*)/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | 2 | $data->{bass} = $2; | |||||||||
| 81 | 2 | $data->{root} = $1; | |||||||||
| 82 | } | ||||||||||
| 83 | 56 | $data->{type} = shift; | |||||||||
| 84 | 56 | $data->{duration} = 0+shift; | |||||||||
| 85 | } | ||||||||||
| 86 | 58 | bless { data => $data }, $pkg; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | =head2 root bass type duration inversion | ||||||||||
| 90 | |||||||||||
| 91 | Accessors can be used to set and/or get these attributes. | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||
| 94 | |||||||||||
| 95 | 4 | ▶ | sub root { shift->_setget( "root", @_ ) } | ||||||||
|
Subroutine
root: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 96 | 1 | ▶ | sub bass { shift->_setget( "bass", @_ ) } | ||||||||
|
Subroutine
bass: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 97 | 2 | ▶ | sub type { shift->_setget( "type", @_ ) } | ||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 98 | 3 | ▶ | sub duration { shift->_setget( "duration", @_ ) } | ||||||||
|
Subroutine
duration: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 99 | 1 | ▶ | sub inversion { shift->_setget( "inversion", @_ ) } | ||||||||
|
Subroutine
inversion: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 100 | |||||||||||
| 101 | =head1 AUTHOR, COPYRIGHT & LICENSE | ||||||||||
| 102 | |||||||||||
| 103 | See L<Music::ChordBot>. | ||||||||||
| 104 | |||||||||||
| 105 | =cut | ||||||||||
| 106 | |||||||||||
| 107 | 6 | 1; | |||||||||