NAME
Music::VoicePhrase - Construct measured phrases of notes
VERSION
version 0.0117
SYNOPSIS
use Music::VoicePhrase ();
my $mvp = Music::VoicePhrase->new;
my $motifs = $mvp->motifs; # using defaults
my $voices = $mvp->voices;
$mvp->motif_num(6); # get fresh
$motifs = $mvp->build_motifs;
$voices = $mvp->build_voices;
DESCRIPTION
A Music::VoicePhrase constructs a measured phrase of voices with both pitch and rhythmic value.
This module is also equipped with handy attributes to make real-time processing work. See the linked script in the "SEE ALSO" section.
ATTRIBUTES
base
$base = $mvp->base;
Base scale note.
Default: C
scale
$scale = $mvp->scale;
Scale name known to the Music::Scales module.
Default: major
octave
$octave = $mvp->octave;
Octave integer from 0 to 9.
Default: 0
pitches_name
$pitches_name = $mvp->pitches_name;
Name for the given pitches, used in real-time processing.
Default: '2 octaves'
pitches
$pitches = $mvp->pitches;
The allowed pitches in MIDI number format.
Default: 2 consecutive octaves given the base note, scale name, and starting octave.
intervals_name
$intervals_name = $mvp->intervals_name;
Name for the given intervals, used in real-time processing.
Default: '-3..-1,1..3'
intervals
$intervals = $mvp->intervals;
Intervals that define the Music::VoiceGen selection.
Default: [-3, -2, -1, 1, 2, 3]
size
$size = $mvp->size;
The number of beats in a phrase. This is usually an integer like 4 beats for a measure. But it can also be a float, as the Music::Duration::Partition module takes fractional numbers. For instance size 2.5 represents 5/8 time. Because a size of <5> represents 5/4 time.
Default: 4
pool
$pool = $mvp->pool;
The pool of note durations, given in Perl MIDI abbreviated notation, that define the Music::Duration::Partition phrase.
Default: ['dhn', 'hn', 'qn']
weights
$weights = $mvp->weights;
Weights that define the Music::Duration::Partition phrase.
Default: [ 1, 2, 2 ]
groups
$groups = $mvp->groups;
Groups that define the Music::Duration::Partition phrase.
Default: [ 0, 0, 0 ]
motif_num
$motif_num = $mvp->motif_num;
The number of motifs to generate by the build_motifs() method.
Default: 4
motifs
$motifs = $mvp->motifs;
The rhythmic motifs given by Music::Duration::Partition.
Default: 4 motifs
voices
$voices = $mvp->voices;
The pitches given by Music::VoiceGen.
Default: 4 voices
patch
$patch = $mvp->patch;
Patch / synth program integer from 0 to 127 used in real-time processing.
Default: 0 (GM piano)
gate
$gate = $mvp->gate;
A possibly fractional amount representing how long a note-length is between 0 and 2. A 0 value means that the note is not played. A 2 means the note is to be held twice as long.
This is used in real-time processing.
Default: 1 (unity)
queue
$queue = $mvp->queue;
Computed attribute for the priority queue used in real-time processing.
index
$index = $mvp->index;
$mvp->index($n);
Computed attribute for the queue index that is used in real-time processing.
Default: 0
note
$note = $mvp->note;
$mvp->note($n);
Computed attribute for the currently selected note that is used in real-time processing.
Default: {}
onsets
$onsets = $mvp->onsets;
Computed attribute for the note onsets used in real-time processing.
channel
$channel = $mvp->channel;
The MIDI channel of the part.
Default: 0
verbose
$verbose = $mvp->verbose;
Show progress.
Default: 0
METHODS
new
$mvp = Music::VoicePhrase->new(%arguments);
Create a new Music::VoicePhrase object.
build_motifs
$motifs = $mvp->build_motifs;
Build a fresh list of motifs based on the .
build_voices
$voices = $mvp->build_voices;
Build a fresh list of voices based on the number of motifs.
increment_index
$i = $mvp->increment_index;
Just add one to the index attribute.
SEE ALSO
https://github.com/ology/Music/blob/master/tones-variation.pl
https://github.com/ology/Phrase-Generator
AUTHOR
Gene Boggs <gene.boggs@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 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.