NAME

Music::MelodicDevice::Ornamentation - Chromatic and diatonic melodic ornamentation

VERSION

version 0.0503

SYNOPSIS

use Music::MelodicDevice::Ornamentation;

my $md = Music::MelodicDevice::Ornamentation->new; # chromatic

$md = Music::MelodicDevice::Ornamentation->new( # diatonic
  scale_note => 'C',
  scale_name => 'major',
  verbose => 1,
);

my $spec = $md->grace_note('qn', 'D5', -1);
$spec = $md->turn('qn', 'D5', 1);
$spec = $md->trill('qn', 'D5', 2, 1);
$spec = $md->mordent('qn', 'D5', 1);
$spec = $md->slide('qn', 'D5', 'F5');

DESCRIPTION

Music::MelodicDevice::Ornamentation provides chromatic and diatonic musical melodic ornamentation methods.

Each returns a note-set specification. This specification is a list of two part array-references: a duration and a pitch. The list duration component is a division of the given duration argument, and is based on the arithmetic of each ornament. The list pitch can vary around the given pitch argument by the given offset, and also depends on the particular ornament re-phrasing.

Since the point is likely to use MIDI-Perl to render these ornaments, to audio, it is handy to know that the pitches in these specifications can be translated to a readable format like this:

$spec = [ map { [ MIDI::Util::midi_format(@$_) ] } @$spec ];
$score->n(@$_) for @$spec;

ATTRIBUTES

scale_note

Default: C

scale_name

Default: chromatic

For the chromatic scale, enharmonic notes are listed as sharps. For a scale with flats, a diatonic scale_name must be used with a flat scale_note.

Please see "SCALES" in Music::Scales for a list of valid scale names.

verbose

Default: 0

Show the progress of the methods.

METHODS

new

$x = Music::MelodicDevice::Ornamentation->new(
  scale_note => $scale_note,
  scale_name => $scale_name,
  verbose => $verbose,
);

Create a new Music::MelodicDevice::Ornamentation object.

grace_note

$spec = $md->grace_note($duration, $pitch, $offset);

Default offset: 1

"Appoggiatura" means emphasis on the grace note. "Acciaccatura" means emphasis on the main note. This module doesn't accent notes. You'll have to do that bit.

turn

$spec = $md->turn($duration, $pitch, $offset);

The note Above, the Principle note (the pitch), the note Below, the Principle note again.

The default offset is 1, but if given as -1, the turn is "inverted" and goes: Below, Principle, Above, Principle.

trill

$spec = $md->trill($duration, $pitch, $number, $offset);

A trill is a number of pairs of notes spread over a given duration. The first of the pair being the given pitch and the second one given by the offset.

Default number: 2

Default offset: 1

mordent

$spec = $md->mordent($duration, $pitch, $offset);

"A rapid alternation between an indicated note [the pitch], the note above or below, and the indicated note again."

An offset of 1 (the default) returns an upper mordent one pitch away. An offset of -1 returns a lower mordent.

So if the pitch is D5, a diatonic upper mordent would be D5 E5 D5. A chromatic lower mordent would be D5 C#5 D5.

slide

$spec = $md->slide($duration, $from, $to);

Play each note in the chromatic scale between the from and to pitches, for the given duration.

SEE ALSO

The t/01-methods.t and eg/* programs in this distribution

Carp

Data::Dumper::Compact

List::SomeUtils

MIDI::Simple

Moo

Music::Duration

Music::Note

Music::Scales

https://en.wikipedia.org/wiki/Ornament_(music)

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 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.