NAME

Music::MelodicDevice::Inversion - Apply melodic inversion to a series of notes

VERSION

version 0.0504

SYNOPSIS

use Music::MelodicDevice::Inversion ();

my @notes = qw(C4 E4 D4 G4 C5); # either named notes or midinums

# Chromatic
my $md = Music::MelodicDevice::Inversion->new;
my $intervals = $md->intervals(\@notes);   # [4, -2, 5, 5]
my $inverted = $md->invert('C4', \@notes); # [C4, G#3, A#3, F3, C3]

# Diatonic
$md = Music::MelodicDevice::Inversion->new(scale_name => 'major');
$intervals = $md->intervals(\@notes);   # [2, -1, 3, 3]
$inverted = $md->invert('C4', \@notes); # [C4, A3, B3, F3, C3]

DESCRIPTION

Music::MelodicDevice::Inversion applies intervallic melodic inversions, both chromatic or diatonic, to a series of ISO formatted or "midinum" notes. Basically, this flips a melody upside-down given a starting note.

While there are a couple modules on CPAN that do various versions of melodic inversion, none appear to apply to an arbitrary series of notes. Hence this module.

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

METHODS

new

$md = Music::MelodicDevice::Inversion->new(
  scale_note => $scale_note,
  scale_name => $scale_name,
  verbose    => $verbose,
);

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

intervals

$intervals = $md->intervals($notes);

Return the positive or negative intervals between successive notes.

invert

$inverted = $md->invert($note, $notes);

Return the inverted series of notes.

SEE ALSO

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

Music::AtonalUtil (contains a similar "invert" method)

MIDI::Praxis::Variation (contains a mystery "inversion" function)

Data::Dumper::Compact

List::SomeUtils

Moo

Music::Scales

https://en.wikipedia.org/wiki/Inversion_(music)#Melodies

https://music.stackexchange.com/a/32508/6683

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.