There is an ongoing outage on the primary CPAN mirror. It is possible to work around the issue by using MetaCPAN as a mirror.

NAME

Music::MelodicDevice::Arpeggiation - Apply arpeggiation patterns to groups of notes

VERSION

version 0.0200

SYNOPSIS

use Music::MelodicDevice::Arpeggiation;

my $arp = Music::MelodicDevice::Arpeggiation->new;

my $arped = $arp->arp([60,64,67], 1, 'updown', 3);

DESCRIPTION

Music::MelodicDevice::Arpeggiation applies arpeggiation patterns to groups of notes.

ATTRIBUTES

type

$arp->type($type);
$type = $arp->type;

Default: up

Arpeggiation named type.

Known types:

up
down
updown
random

duration

$arp->duration($duration);
$duration = $arp->duration;

Default: 1 (quarter-note)

Duration over which to distribute the arpeggiated pattern of notes.

repeats

$arp->repeats($repeats);
$repeats = $arp->repeats;

Default: 1

Number of times to repeat the arpeggiated pattern of notes.

verbose

$arp->verbose($verbose);
$verbose = $arp->verbose;

Default: 0

Show progress.

METHODS

new

$x = Music::MelodicDevice::Arpeggiation->new(
  scale_note => $scale_note,
  scale_name => $scale_name,
  verbose    => $verbose,
);

Create a new Music::MelodicDevice::Arpeggiation object.

arp

$notes = $arp->arp(\@pitches); # use object defaults
$notes = $arp->arp(\@pitches, $duration);
$notes = $arp->arp(\@pitches, $duration, $type);
$notes = $arp->arp(\@pitches, $duration, $type, $repeats);

Return a list of lists of d# MIDI-Perl strings with the pitches indexed by the arpeggiated pattern built from the given type. These MIDI-Perl duration strings are distributed evenly across the given duration.

build_pattern

my $pattern = $self->build_pattern($type, $notes);

Return an array reference of notes indexes, based on the type, if known.

arp_type

$all_types = $self->arp_type # get everything
$coderef = $self->arp_type($type); # get the value
$self->arp_type($type, $coderef); # set a new type

For no arguments, return the full hash reference of all arpeggiation types. For a single argument, return the code-reference value of that type, of known. If two arguments are given, add the named type to the known arpeggiation types with its code-reference value.

Known types and their code-ref values are:

up     => sub { my ($notes) = @_; return [ 0 .. $#$notes ] },
down   => sub { my ($notes) = @_; return [ reverse(0 .. $#$notes) ] },
random => sub { my ($notes) = @_; return [ map { rand @$notes } @$notes ] },

SEE ALSO

The t/01-methods.t program in this distribution

Array::Circular

Data::Dumper::Compact

Moo

AUTHOR

Gene Boggs <gene.boggs@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2025 by Gene Boggs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.