Music::MelodicDevice::Transposition - Apply chromatic and diatonic transposition to notes
version 0.0601
use Music::MelodicDevice::Transposition; my @notes = qw(C4 E4 D4 G4 C5); # either named notes or midinums # Chromatic my $md = Music::MelodicDevice::Transposition->new( notes => \@notes, ); my $transposed = $md->transpose(2); # [D4, F#4, E4, A4, D5] $transposed = $md->transpose(4); # [E4, G#4, F#4, B4, E5] $transposed = $md->transpose(4, \@notes); # same thing # Diatonic $md = Music::MelodicDevice::Transposition->new(scale_name => 'major'); $md->notes(\@notes); $transposed = $md->transpose(2); # [E4, G4, F4, B4, E5] $transposed = $md->transpose(4); # [G4, B4, A4, D5, G5] $md->notes([qw(C4 E4 G4)]); $transposed = $md->transpose(4); # [G4, B4, D5]
Music::MelodicDevice::Transposition applies transposition, both chromatic or diatonic, to a series of ISO or "midinum" formatted notes.
Music::MelodicDevice::Transposition
While there are modules on CPAN that do chromatic transposition, none appear to apply diatonic transposition 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.
$md->notes(\@notes);
The list of notes to use in transposition operations.
This can be overriden with a notes argument given to the transposition method.
Default: [] (no notes)
[]
Default: 0
0
$md = Music::MelodicDevice::Transposition->new( scale_note => $scale_note, scale_name => $scale_name, notes => \@notes, verbose => $verbose, );
Create a new Music::MelodicDevice::Transposition object.
$transposed = $md->transpose($offset); $transposed = $md->transpose($offset, \@notes);
Return the transposed list of notes given an offset appropriately based on the number of notes in the chosen scale.
The t/01-methods.t test and the eg/* example files
Data::Dumper::Compact
List::SomeUtils
Moo
Music::Scales
Gene Boggs <gene@cpan.org>
This software is copyright (c) 2022 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::Transposition, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Music::MelodicDevice::Transposition
CPAN shell
perl -MCPAN -e shell install Music::MelodicDevice::Transposition
For more information on module installation, please visit the detailed CPAN module installation guide.