NAME
Types::Music - Type Library for Music Programming
VERSION
version 0.0200
SYNOPSIS
use Moo;
use Types::Music -all;
has bars => (
is => 'ro',
isa => PosInt,
default => '4',
);
has iso_note => (
is => 'ro',
isa => Named_Note_Octave,
default => 'C4',
);
DESCRIPTION
This is a type constraint library for developing music software.
USAGE
use Types::Music qw(:types);-
Exports all types by name.
use Types::Music qw(:is);-
Exports all
is_TypeName functions. use Types::Music qw(:assert);-
Exports all
assert_TypeName functions. use Types::Music qw(:to);-
Exports all
to_TypeName functions. use Types::Music qw(+TypeName);-
Exports TypeName and all related functions.
use Types::Music qw(:all);-
Exports everything.
TYPES
PosInt
A positive integer. This can be used for things like beats per minute, number of measures (or "bars"), beats, etc.
Octave
A numeric octave. Usually 1 to 6. Higher and it's not really audible. Zero 0 is special cased to allow specific module behavior.
Signature
A string representing a time signature, like 3/4. The Signature is a fraction with Beats as numerator and Divisions as denominator.
Key
A key note, like C, C#, Bb, etc.
Named_Note
A named note, in either tradional or MIDI-Perl notation, like C, C#, Cs, Bb, Bf, etc.
Named_Note_Octave
A named note with octave, like C4, C#5, Cs5, Bb2, Bf2, etc.
Mode
A mode name. The known modes are:
ionian / major
dorian
phrygian
lydian
mixolydian
aeolian / minor
locrian
FUNCTIONS
is_PosInt
Returns true if the passed value can be used as a "PosInt".
assert_PosInt
Returns the passed value if and only if it can be used as a "PosInt", otherwise an exception is thrown.
is_Octave
Returns true if the passed value can be used as an "Octave".
assert_Octave
Returns the passed value if and only if it can be used as an "Octave", otherwise an exception is thrown.
is_Signature
Returns true if the passed value can be used as a time signature "Signature".
assert_Signature
Returns the passed value if and only if it can be used as a time signature "Signature", otherwise an exception is thrown.
is_Key
Returns true if the passed value can be used as a "Key".
assert_Key
Returns the passed value if and only if it can be used as a "Key", otherwise an exception is thrown.
is_Named_Note
Returns true if the passed value can be used as a "Named_Note".
assert_Named_Note
Returns the passed value if and only if it can be used as a "Named_Note", otherwise an exception is thrown.
is_Named_Note_Octave
Returns true if the passed value can be used as a "Named_Note_Octave".
assert_Named_Note_Octave
Returns the passed value if and only if it can be used as a "Named_Note_Octave", otherwise an exception is thrown.
is_Mode
Returns true if the passed value can be used as a "Mode".
assert_Mode
Returns the passed value if and only if it can be used as a "Mode", otherwise an exception is thrown.
SEE ALSO
AUTHOR
Gene Boggs <gene.boggs@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2025 by Gene Boggs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.