NAME
Music::CreatingRhythms - Perl from the C code of the book
VERSION
version 0.0100
SYNOPSIS
use Music::CreatingRhythms ();
my $mcr = Music::CreatingRhythms->new;
my $foo = $mcr->foo('...');
DESCRIPTION
Music::CreatingRhythms
provides the combinatorial algorithms described in the book, "Creating Rhythms", by Hollos. These algorithms are ported directly from the C, and are pretty fast. Please see the link below for more information.
NB: Arguments are sometimes switched between book and software.
Additionally, this module provides utilities to transform sequences that are not part of the book, but are nonetheless handy.
ATTRIBUTES
verbose
$verbose = $mcr->verbose;
Show progress. * This is not showing anything yet, however.
METHODS
new
$mcr = Music::CreatingRhythms->new(verbose => 1);
Create a new Music::CreatingRhythms
object.
chsequl
$compositions = $mcr->chsequl($n);
Generate the upper or lower Christoffel word for p/q
Arguments:
t = required type of word (u: upper, l: lower)
p = required numerator of slope
q = required denominator of slope
n = optional number of terms to generate, default: p+q
comp
$compositions = $mcr->comp($n);
Generate all compositions of n.
compa
$compositions = $mcr->compa($n, @intervals);
Generate compositions of n with allowed intervals p1, p2, ... pn.
compam
$compositions = $mcr->compam($n, $m, @intervals);
Generate compositions of n with m parts and allowed intervals p1, p2, ... pn.
compm
$compositions = $mcr->compm($n, $m);
Generate all compositions of n into m parts.
debruijn_n
$sequence = $mcr->debruijn_n($n);
Generate the largest de Bruijn sequence of order n.
euclid
$sequence = $mcr->euclid($n, $m);
Generate a Euclidean rhythm given n onsets distributed over m beats.
invert_at
$sequence = $mcr->invert_at($n, $parts);
Invert a section of a parts binary sequence at n.
neck
$necklaces = $mcr->neck($n);
Generate all binary necklaces of length n.
necka
$necklaces = $mcr->necka($n, @intervals);
Generate binary necklaces of length n with allowed intervals p1, p2, ... pn.
neckam
$necklaces = $mcr->neckam($n, $m, @intervals);
Generate binary necklaces of length n with m ones, and allowed intervals p1, p2, ... pn.
neckm
$necklaces = $mcr->neckm($n, $m);
Generate all binary necklaces of length n with m ones.
part
$partitions = $mcr->part($n);
Generate all partitions of n.
parta
$partitions = $mcr->parta($n, @intervals);
Generate all partitions of n with allowed intervals p1, p2, ... pn.
partam
$partitions = $mcr->partam($n, $m, @intervals);
Generate all partitions of n with m parts from the intervals p1, p2, ... pn.
partm
$partitions = $mcr->partm($n, $m);
Generate all partitions of n into m parts.
permute
$all_permutations = $mcr->permute(\@parts);
Return all permutations of the given parts list as an array-reference of array-references.
(For an efficient iterator, check out the Algorithm::Combinatorics module.)
reverse_at
$sequence = $mcr->reverse_at($n, $parts);
Reverse a section of a parts sequence at n.
rotate_n
$sequence = $mcr->rotate_n($n, $parts);
Rotate a necklace of the given parts, n times.
SEE ALSO
https://abrazol.com/books/rhythm1/ "Creating Rhythms"
The t/01-methods.t and eg/* programs included with this distribution.
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2023 by Gene Boggs.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)