NAME

Music::CreatingRhythms - Ported Perl from the book's C code

VERSION

version 0.0200

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 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;

Create a new Music::CreatingRhythms object.

cfcv

$convergent = $mcr->cfcv(@terms);

Calculate a continued fraction convergent given the terms.

cfsqrt

$terms = $mcr->cfsqrt($n, $m);

Calculate the continued fraction for sqrt(n) to m digits, where n and m are integers.

chsequl

$sequence = $mcr->chsequl($t, $p, $q);
$sequence = $mcr->chsequl($t, $p, $q, $n);

Generate the upper or lower Christoffel word for p and 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.

permi

$all_permutations = $mcr->permi(\@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.

Algorithm::Combinatorics

Data::Munge

Integer::Partition

List::Util

Math::Sequence::DeBruijn

Moo

Music::AtonalUtil

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)