Music::MelodicDevice::Inversion - Apply melodic inversion to a series of notes
version 0.0504
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]
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.
Music::MelodicDevice::Inversion
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.
Default: C
C
Default: chromatic
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.
Default: 0
0
$md = Music::MelodicDevice::Inversion->new( scale_note => $scale_note, scale_name => $scale_name, verbose => $verbose, );
Create a new Music::MelodicDevice::Inversion object.
$intervals = $md->intervals($notes);
Return the positive or negative intervals between successive notes.
$inverted = $md->invert($note, $notes);
Return the inverted series of notes.
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
Gene Boggs <gene@cpan.org>
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.
To install Music::MelodicDevice::Inversion, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Music::MelodicDevice::Inversion
CPAN shell
perl -MCPAN -e shell install Music::MelodicDevice::Inversion
For more information on module installation, please visit the detailed CPAN module installation guide.