The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

VERSION

version 0.0706

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,
  );

  # With named notes
  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');

  # With integer pitches
  $spec = $md->grace_note('qn', 74, -1);
  $spec = $md->turn('qn', 74, 1);
  $spec = $md->trill('qn', 74, 2, 1);
  $spec = $md->mordent('qn', 74, 1);
  $spec = $md->slide('qn', 74, 77);

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.

If the pitch is given as an integer, then specs with integers are returned.

Since the point is likely to use MIDI-Perl to render these ornaments, to audio, it is handy to know that named pitches in these specifications can be translated with the MIDI::Util midi_format function:

  my @spec = ([qw(en C4)], [qw(sn C#4)], [qw(qn D4)], ...);
  @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, use a diatonic scale_name 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

NB: I believe that "appoggiatura" means emphasis on the grace note, and "acciaccatura" means emphasis on the principle 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, followed by the Principle note again.

For example: D4 C4 B3 C4 (where C4 is the Principle note)

Default offset: 1

But if the offset is 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."

Default offset: 1

An offset of 1 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, in say C major, would be D5 E5 D5. A chromatic lower mordent would be D5 C#5 D5.

slide

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

Return a specification where the notes move (in the chromatic scale) between the from and to pitches, for the given duration.

This ornament is also known as the "glissando."

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::Scales

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

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

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