App-MusicTools

 view release on metacpan or  search on metacpan

bin/canonical  view on Meta::CPAN

Raw pitch numbers or lilypond note names (though only in the default
"nederlands" language) are accepted.

Run perldoc(1) on canonical for additional documentation.

EOH
    exit 64;
}

sub emit_help_modal {
    warn <<"EOH";
Usage: canonical [opts] modal --input=mode --output=mode notes...

Modal interval mapping. In particular:

  --chrome=N     Chrome weighting. Default is 0. See Music::Canon.
  --duration=N   Set default duration value.

  --ep=N         Set the start and end pitch via set_modal_pitches().
  --sp=N         Necessary if phrase begins on non-tonic scale degree.

  --input=mode   Set the input and output modes. These may be Music::Scales
  --output=mode  names, or Forte Numbers. Major to Major used by default.

  --nos          Allow for non-octave scales. Necessary if doing crazy
                 things with intervals in the --input or --output options.

  --undef=N      Use N for notes that cannot be converted.

General options include:

  --contrary     Compute canon in contrary motion.
  --flats        Print notes with flats instead of sharps.
  --map          Prints original and output notes or numbers one per line.
  --raw          Emit raw pitch numbers in output instead of note names.
  --relative=N   Input is relative to lilypond note N (absolute notation is
                 assumed by default otherwise).
  --retrograde   Reverse the output voice.
  --transpose=N  Transpose output voice by semitones or to a lilypond note.

Raw pitch numbers or lilypond note names (though only in the default
"nederlands" language) are accepted.

Run perldoc(1) on canonical for additional documentation.

EOH
    exit 64;
}

sub emit_phrase {
    my ( $is_multicolumn, $orig, $new, $rest ) = @_;

    $is_multicolumn = 1 if $Flag_Map;

    # As a not-compatible change, this *always* used to emit space-
    # delimited values though for multicolumness (and to avoid a
    # subsequent `tr ' ' '\n'`) switched output to be delimited by
    # newlines.
    if ($is_multicolumn) {
        while (@$new) {
            say join( ' ',
                $Flag_Map ? shift @$orig : (),
                grep { defined } shift @$new,
                shift @$rest );
        }
    } else {
        print join( ' ', @$new ), "\n";
    }
}

__END__

=head1 NAME

canonical - compute canon voices via the Music::Canon module

=head1 SYNOPSIS

  $ canonical --contrary --retrograde exact c cis d
  $ canonical --transpose=12 exact c ees g
  $ canonical --raw --contrary exact 1 2 3

  $ canonical modal --input=lydian --output=locrian c e g

Raw pitch numbers or lilypond note names (though only in the default
"nederlands" language) are accepted. Consult the C<lilypond> "Notation
Reference" section "Note names in other languages" for the syntax.

=head1 DESCRIPTION

Command line interface to the mapping methods present in the
L<Music::Canon> module. Certain questions might be better answered by
coding directly against L<Music::Canon>; see the C<eg/> directory under
the distribution of that Perl module for examples.

Note that input via the command line is handled differently from notes
supplied via standard input; in the first case, all of the input is
considered to be notes. In the second case, only the first column
(delimited by a space) is considered to be note material, and the other
columns should be passed through unchanged.

  $ echo 42 cat | canonical exact --transpose=a
  a cat

=head1 GLOBAL OPTIONS

This program currently supports the following global command line
switches. These can also be specified to the underlying modes.

=over 4

=item B<--contrary> | B<-c> | B<--nocontrary>

Whether to compute the output line in contrary motion or not (default
is not to).

=item B<--duration>=I<value>

Set the default duration for rhythm handling (C<4> by default). Rhythm
handling should be transparent, though does not extend to tied notes,
triplet groups, or grace notes.



( run in 1.605 second using v1.01-cache-2.11-cpan-ff9377addf4 )