NAME
Types::Music - Type Library for Music Programming
VERSION
version 0.0104
SYNOPSIS
use Moo;
use Types::Music -all;
has named_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
BPM
A positive integer beats per minute.
Bars
A positive integer number of bars (or measures).
Beats
A positive integer number of beats per measure.
Divisions
A positive integer number of divisions.
Signature
A string representing a time signature, like 3/4
. The Signature is a fraction with Beats as numerator and Divisions as denominator.
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.
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_BPM
Returns true if the passed value can be used as a "BPM".
assert_BPM
Returns the passed value if and only if it can be used as a "BPM", otherwise an exception is thrown.
is_Bars
Returns true if the passed value can be used as the number of "Bars".
assert_Bars
Returns the passed value if and only if it can be used as the number of "Bars", otherwise an exception is thrown.
is_Beats
Returns true if the passed value can be used as the number of "Beats".
assert_Beats
Returns the passed value if and only if it can be used as the number of "Beats", otherwise an exception is thrown.
is_Divisions
Returns true if the passed value can be used as the number of "Divisions".
assert_Divisions
Returns the passed value if and only if it can be used as the number of "Divisions", 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_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_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.