App-MusicTools

 view release on metacpan or  search on metacpan

bin/atonal-util  view on Meta::CPAN

sub whatscalesfit {
    my (@args) = @_;
    GetOptionsFromArray( \@args, @Std_Opts ) or print_help();
    $Lyu->chrome('flats') if $Flag_Flat;

    my $pset = args2pitchset(@args);
    for my $p (@$pset) {
        $p %= $scale_degrees;
    }

    my @scales = qw/major dorian phrygian lydian mixolydian aeolian locrian blues/;
    push @scales, "harmonic minor", "melodic minor", "hungarian minor";

    for my $scale (@scales) {
        my @asc = get_scale_nums($scale);
        _fit_scale( $scale, $pset, \@asc );

        my @dsc = get_scale_nums( $scale, 1 );
        if ( join( ' ', @asc ) ne join( ' ', reverse @dsc ) ) {
            _fit_scale( $scale, $pset, \@dsc, 1 );
        }

bin/scalemogrifier  view on Meta::CPAN

#
# XXX probably should standardize on Music::Scale (unmaintained?) or use
# Masaya Yamaguchi's complete scale system, plus offer ability for user
# to define new scales.
my %modes = (
    ionian     => [qw(2 2 1 2 2 2 1)],
    lydian     => [qw(2 2 2 1 2 2 1)],
    mixolydian => [qw(2 2 1 2 2 1 2)],
    dorian     => [qw(2 1 2 2 2 1 2)],
    amdorian   => [qw(2 1 2 1 2 2 2)],
    aeolian    => [qw(2 1 2 2 1 2 2)],
    mminor     => [qw(2 1 2 2 2 2 1)],
    hminor     => [qw(2 1 2 2 1 3 1)],
    hunminor   => [qw(2 1 3 2 1 3 1)],
    phrygian   => [qw(1 2 2 2 1 2 2)],
    locrian    => [qw(1 2 2 1 2 2 2)],
    'p-major'  => [qw(2 2 3 2 3)],
    'p-minor'  => [qw(3 2 2 3 2)],
    'p-sakura' => [qw(1 4 2 1 4)],
);
$modes{'major'} = $modes{'ionian'};
$modes{'minor'} = $modes{'aeolian'};

# Note names for program output
my %num2note = (
    'ly-sharp' => {qw/0 c 1 cis 2 d 3 dis 4 e 5 f 6 fis 7 g 8 gis 9 a 10 ais 11 b/},
    'ly-flat'  => {qw/0 c 1 des 2 d 3 ees 4 e 5 f 6 ges 7 g 8 aes 9 a 10 bes 11 b/},
);
my $num2note_flavor = 'ly-';

# Not The Scale, but to map back to That Other Scale.
my $DEG_IN_SCALE = 12;

bin/scalemogrifier  view on Meta::CPAN


  $ scalemogrifier
  c d e f g a b c'

The list of accepted lilypond note names and other elements include:

  c cis des d dis ees e f fis ges g gis aes a ais bes b   nl

Available named modes include:

  aeolian amdorian dorian hminor hunminor ionian locrian lydian
  major minor mixolydian mminor phrygian

=head1 DESCRIPTION

Generates notes of arbitrary scales (subsets of the Western 12-tone
chromatic system) from a specified starting note in a specified
direction and so forth from other options.

The output is in lilypond absolute format. The default scale is The
Major Scale, but that's easy to adjust to say C Minor:

bin/vov  view on Meta::CPAN

# pitches; adjust these if using some other scale system.
my $MAX_SCALE_DEGREE = 7;
# Western system of 7 scale degrees allows for at most a 13th chord
# before repeats; the following generalizes to arbitrary degrees.
my $MAX_CHORD_FACTOR =
  ( $MAX_SCALE_DEGREE % 2 == 0 ? $MAX_SCALE_DEGREE : $MAX_SCALE_DEGREE * 2 ) -
  1;
my $DEFAULT_CHORD_FACTOR = 5;    # a 5th
my $DEG_IN_SCALE         = 12;
my @MODES =
  qw/aeolian amdorian dorian hminor hunminor ionian locrian lydian major minor mixolydian mminor phrygian/;
my $mode_name = 'major';

my $atu = Music::AtonalUtil->new;
# Chords generated from the root up, with no notion of register
my $lyu = Music::LilyPondUtil->new( ignore_register => 1, keep_state => 0 );

my $output_tmpl = '%{chord}' . "\n";

GetOptions(
    'factor=i'      => \my $Default_Factor,

t/atonal-util.t  view on Meta::CPAN

    args   => [qw(transpose --transpose=7 0 6 11)],
    stdout => "7,1,6\n",
};
command {
    args   => [qw(transpose_invert --transpose=3 1 2 3)],
    stdout => "2,1,0\n",
};
command {
    args   => [qw(whatscalesfit c d e f g a b)],
    stdout =>
      "C  Major                     c     d     e     f     g     a     b\nD  Dorian                    d     e     f     g     a     b     c\nE  Phrygian                  e     f     g     a     b     c     d\nF  Lydian                    f     g   ...
};

# custom tests that the old Test::Cmd code had trouble with

my ( $result, $status, $stdout, $stderr ) =
  command { args => [qw(fnums)], stdout => qr/^3-1\s+0,1,2\s+210000/ };
my $lines = 0;
$lines++ while $$stdout =~ m/^[3-9]-[1-9Z]/gm;
is( $lines, 208, 'forte numbers count' );



( run in 0.588 second using v1.01-cache-2.11-cpan-98e64b0badf )