App-MusicTools
view release on metacpan or search on metacpan
bin/atonal-util view on Meta::CPAN
}
}
sub transpose {
my (@args) = @_;
GetOptionsFromArray( \@args, @Std_Opts, 'transpose|n=s' => \my $t, )
or print_help();
$Lyu->chrome('flats') if $Flag_Flat;
$t //= 0;
my $pset = args2pitchset(@args);
# if a number, transpose by that; if note, transpose to that note
if ( !looks_like_number($t) ) {
$t = $Lyu->notes2pitches($t) - $pset->[0];
}
emit_pitch_set( $Atu->transpose( $t, $pset ), rs => $Flag_Record_Sep );
}
sub transpose_invert {
my (@args) = @_;
GetOptionsFromArray(
\@args, @Std_Opts,
'axis|a=s' => \my $axis,
'transpose|t=s' => \my $t,
) or print_help();
$Lyu->chrome('flats') if $Flag_Flat;
my $pset = args2pitchset(@args);
$axis = defined $axis ? $Lyu->notes2pitches($axis) : 0;
# if a number, transpose by that; if note, transpose to that note
$t //= 0;
if ( !looks_like_number($t) ) {
$t = $Lyu->notes2pitches($t) - $pset->[0];
}
emit_pitch_set( $Atu->transpose_invert( $t, $axis, $pset ),
rs => $Flag_Record_Sep );
}
sub variances {
my (@args) = @_;
GetOptionsFromArray( \@args, @Std_Opts ) or print_help();
$Lyu->chrome('flats') if $Flag_Flat;
emit_pitch_set( [ $Atu->variances( @{ stdin2pitchsets() } ) ],
rs => $Flag_Record_Sep );
}
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 );
}
}
}
sub zrelation {
emit_pitch_set( [ $Atu->zrelation( @{ stdin2pitchsets() } ) ], lyflag => 0 );
}
END {
# Report problems when writing to stdout (perldoc perlopentut)
unless ( close(STDOUT) ) {
die "error: problem closing STDOUT: $!\n";
}
}
__END__
=head1 NAME
atonal-util - routines for atonal composition and analysis
=head1 SYNOPSIS
Prime form and APIC vector for a pitch set:
$ atonal-util basic --ly f fis c
Apply a series of transformations to a pitch set:
$ cat rules
retrograde
invert 6
transpose 1
$ atonal-util recipe --file=rules 0 11 3
4,8,7
Among many other options.
=head1 DESCRIPTION
Routines for atonal music composition and analysis, plus other music
theory or composition related tasks. Global options and a mode must be
supplied, followed by any mode specific arguments. Most modes accept
pitch sets, though some perform other tasks and thus expect various
input formats. Pitch sets can be read as arguments or from standard
input; some modes require two pitch sets that must be supplied one per
line on standard input.
The output will vary depending on the mode, and may include Cope tension
numbers (average, min, max tension for the pitch set). Other programs
should not be written to use this program, as the output may change. Use
( run in 1.910 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )