NAME Types::MIDI - Type library for MIDI VERSION version v0.0.5 SYNOPSIS use Moo; use Types::MIDI -all; has volume => ( is => 'ro', isa => Velocity, default => 100, ); has a440 => ( is => 'ro', isa => Note, default => 69, ); has electric_snare => ( is => 'ro', isa => PercussionNote, coerce => 1, default => 'Electric Snare', ); DESCRIPTION This is a type constraint library intended to be useful for those developing music software using the MIDI (Musical Instrument Digital Interface) specification. It is a work in progress driven by real-world usage, and as such does not yet necessarily have a stable interface. Once it reaches version 1.0, though, the author does not intend to introduce any breaking changes without a corresponding increase in the major version number. OVERVIEW Because this leverages Type::Library, it should be usable in a variety of Perl object systems, including Moo and Moose. By default, it exports nothing into the consumer's namespace; however, in addition to specifying individual functions in the "use" in perlfunc statement, you can also provide or combine the following tags to export groups of functions: "use Types::MIDI qw(:types);" Exports all types by name into the namespace. "use Types::MIDI qw(:is);" Exports all "is_"*TypeName* functions into the namespace. "use Types::MIDI qw(:assert);" Exports all "assert_"*TypeName* functions into the namespace. "use Types::MIDI qw(:to);" Exports all "to_"*TypeName* functions into the namespace. "use Types::MIDI qw(+"*TypeName*");" Exports *TypeName* and all related functions into the namespace. "use Types::MIDI qw(:all);" Exports everything. This library also inherits from Exporter::Tiny; consult Exporter::Tiny::Manual::Importing for ways to customize how functions are imported, such as renaming or omitting certain names. Also note that the tags listed above may be preceded with a "-" (hyphen) instead of a ":" (colon); Perl's auto-quoting of barewords thus enables you to import a tag group of functions like so: use Types::MIDI -all; TYPES Channel An integer from 0 to 15 corresponding to a MIDI Channel. Velocity An integer from 0 to 127 corresponding to a MIDI velocity. Note An integer from 0 to 127 corresponding to a MIDI note number. PercussionNote A "Note" from 27 through 87, corresponding to a "Note" number in the General MIDI 2 Percussion Sound Set. This type can also coerce case-insensitive "NonEmptySimpleStr" in Types::Common::Strings of instrument names in the General MIDI 2 Percussion Sound Set, returning the corresponding "Note". FUNCTIONS is_Channel Returns true if the passed value can be used as a "Channel". assert_Channel Returns the passed value if and only if it can be used as a "Channel"; otherwise it throws an exception. is_Velocity Returns true if the passed value can be used as a "Velocity". assert_Velocity Returns the passed value if and only if it can be used as a "Velocity"; otherwise it throws an exception. is_Note Returns true if the passed value can be used as a "Note". assert_Note Returns the passed value if and only if it can be used as a "Note"; otherwise it throws an exception. is_PercussionNote Returns true if the passed value can be used as a "PercussionNote". assert_PercussionNote Returns the passed value if and only if it can be used as a "PercussionNote"; otherwise it throws an exception. to_PercussionNote Coerces the passed value to a "PercussionNote". SEE ALSO * *MIDI 1.0 Detailed Specification (Document Version 4.2.1)*, revised February 1996 by the MIDI Manufacturers Association: * Appendix B: GM 2 Percussion Sound Set in *General MIDI 2 (Version 1.2a)*, published February 6, 2007 by the MIDI Manufacturers Association: BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. AUTHOR Mark Gardner COPYRIGHT AND LICENSE This software is copyright (c) 2025 by Mark Gardner. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.