| 1 | package Types::Music; | ||
| 2 | |||
| 3 | # ABSTRACT: Type Library for Music Programming | ||
| 4 | |||
| 5 | 2 | our $AUTHORITY = 'cpan:GENE'; | |
| 6 | |||
| 7 | 2 | our $VERSION = '0.0200'; | |
| 8 | |||
| 9 | 2 | ▶ | use 5.016; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 2 | ▶ | use Types::Standard qw(StrMatch); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 2 | ▶ | use Type::Library 2.000000 |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 2 | -extends => [qw( | |
| 17 | Types::Common::Numeric | ||
| 18 | Types::Common::String | ||
| 19 | )], | ||
| 20 | -declare => qw( | ||
| 21 | PosInt | ||
| 22 | Octave | ||
| 23 | Signature | ||
| 24 | Key | ||
| 25 | Named_Note | ||
| 26 | Named_Note_Octave | ||
| 27 | Mode | ||
| 28 | 2 | ); | |
| 29 | |||
| 30 | 2 | ▶ | use Type::Utils 2.000000 -all; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 31 | |||
| 32 | 2 | declare PosInt, | |
| 33 | as PositiveInt; | ||
| 34 | |||
| 35 | 2 | declare Octave, | |
| 36 | as PositiveOrZeroInt; # the zero-octave means "use pitch-class" in some module of mine... | ||
| 37 | |||
| 38 | 2 | declare Signature, | |
| 39 | as StrMatch[ qr/^[1-9]\d?\/[1-9]\d?$/ ]; | ||
| 40 | |||
| 41 | 2 | declare Key, | |
| 42 | as StrMatch[ qr/^[A-G][#b]?$/ ]; | ||
| 43 | |||
| 44 | 2 | declare Named_Note, | |
| 45 | as StrMatch[ qr/^[A-G][#bsf]?$/ ]; | ||
| 46 | |||
| 47 | 2 | declare Named_Note_Octave, | |
| 48 | as StrMatch[ qr/^[A-G][#bsf]?\d$/ ]; | ||
| 49 | |||
| 50 | 2 | my %modes; | |
| 51 | 2 | @modes{qw( | |
| 52 | ionian major | ||
| 53 | dorian | ||
| 54 | phrygian | ||
| 55 | lydian | ||
| 56 | mixolydian | ||
| 57 | aeolian minor | ||
| 58 | locrian | ||
| 59 | )} = undef; | ||
| 60 | declare Mode, | ||
| 61 | 2 | ▶ | as NonEmptyStr, where { exists $modes{$_} }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 62 | |||
| 63 | 2 | 1; | |
| 64 | |||
| 65 | __END__ | ||