NAME
Music::LilyPondUtil - utility methods for lilypond data
SYNOPSIS
use Music::LilyPondUtil;
my $lyu = Music::LilyPondUtil->new;
my $note = $lyu->p2ly(60) # c'
$lyu->mode('relative');
my @bach = $lyu->p2ly(qw/60 62 64 65 62 64 60 67 72 71 72 74/)
# c d e f d e c g' c b c d
$lyu->keep_state(0);
$lyu->p2ly(qw/0 1023 79 77 -384/); # c dis g f c
$lyu->chrome('flats');
$lyu->p2ly(qw/2 9 5 2 1 2/); # d a f d des d
DESCRIPTION
Utility methods for interacting with lilypond, most notably for the conversion of random integers to lilypond note names. The Western 12- tone system is assumed.
METHODS
The module will throw errors via croak if an abnormal condition is encountered.
- new optional params
-
Constructor. Optional parameters include:
keep_state a boolean, turned on by default, that will maintain state on the previous pitch in the p2ly call. State is not maintained across separate calls to p2ly; to enable that behavior, enable the sticky_state param.
Disabling this option will remove all register notation from both
relative
andabsolute
modes.mode to set
absolute
orrelative
mode.chrome to set the accidental style (
sharps
orflats
).p2n_hook to set a custom code reference for the pitch to note conversion (see source for details).
sticky_state a boolean, disabled by default, that if enabled, will maintain the previous pitch state across separate calls to p2ly, assuming keep_state is also enabled, and again only in
relative
mode.
- chrome optional sharps or flats
-
Get/set accidental style.
- clear_prev_pitch
-
Wipes out the previous pitch (the state variable used with sticky_state enabled in
relative
mode to maintain state across multiple calls to p2ly). - keep_state optional boolean
-
Get/set keep_state param.
- mode optional relative or absolute
-
Get/set the mode of operation.
- notes2pitches list of simple note names
-
Converts note names to pitches. Only recognizes limited set of lilypond note names, and does not know about registers or other note metadata. Returns list of pitches.
- p2ly list of pitches or whatnot
-
Converts a list of pitches (integers or objects that have a pitch method that returns an integer) to a list of lilypond note names. Unknown data will be passed through as is. Returns said converted list.
- prev_pitch optional pitch
-
Get/set previous pitch (the state variable used with sticky_state enabled in
relative
mode to maintain state across multiple calls to p2ly). - sticky_state optional boolean
-
Get/set sticky_state param.
SEE ALSO
http://www.lilypond.org/
Music::AtonalUtil whose
atonal-util
command uses this module to convert pitch numbers into lilypond note names for more readable output.
AUTHOR
Jeremy Mates, <jmates@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Jeremy Mates
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.16.1 or, at your option, any later version of Perl 5 you may have available.