NAME
Music::MelodicDevice::Arpeggiation - Apply arpeggiation patterns to groups of notes
VERSION
version 0.0502
SYNOPSIS
use Music::MelodicDevice::Arpeggiation ();
my $arp = Music::MelodicDevice::Arpeggiation->new;
# arpeggiate the 'updown' pattern
my $arped = $arp->arp(['C4','E4','G4'], 1, 'updown');
# [['d24', 'C4'],['d24', 'E4'],['d24', 'G4'],['d24', 'E4']]
$arped = $arp->arp([60,64,67], 1, 'updown', 3); # midinums repeated 3 times
# set a new pattern type
$arp->arp_type('my_type', sub { my ($notes); return [0,2,1] });
DESCRIPTION
Music::MelodicDevice::Arpeggiation applies arpeggiation patterns to groups of notes that can be used with MIDI-Perl.
ATTRIBUTES
type
$arp->type($type);
$type = $arp->type;
Default: up
Arpeggiation named type.
Known types:
up
down
updown
random
converge
diverge
pedal_up
pedal_down
pedal_updown
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(
type => $type,
duration => $duration,
repeats => $repeats,
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 MIDI-Perl notes of the form, ['d16','E4'].
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.
converge
Return a list of notes from the outer extremes to the middle.
diverge
Return a list of notes from the middle to the outer extremes.
pedal_up
Return a list of notes that climb by repeatedly returning to the lowest note between each successive, higher note. For example, given four notes (0,1,2,3), the returned pattern is (0,1,0,2,0,3).
pedal_down
Return a list of notes that descend by repeatedly returning to the highest note between each successive, lower note. For example, given four notes (0,1,2,3), the returned pattern is (3,2,3,1,3,0).
pedal_updown
Return a list of notes that climb to the highest note through the lowest ("pedal") note, then descend back down to the lowest note through the highest note as the new pedal. For example, given four notes (0,1,2,3), the returned pattern is (0,1,0,2,0,3,2,3,1,3,0).
SEE ALSO
The tests, t/01-methods.t and the eg/* programs in this distribution.
AUTHOR
Gene Boggs <gene.boggs@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2025-2026 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.