NAME

Peta::Synth::Voice - a sounding note: partials, noise, envelope, pitch

VERSION

version 0.2610180

SYNOPSIS

my $voice = Peta::Synth::Voice->new(Peta::Synth::Patch::program(0),
    key => 60, velocity => 100, rate => 48000, partials => 48, start => 0);

DESCRIPTION

The voice model: sine partials, a plucked string (Karplus-Strong), four FM operators, up to three bands of white noise and noise on the partials, under an envelope; a filter that moves over the partials; routes of modulation from velocity, key, the channel's controllers, a second envelope and two LFOs. Made from a Peta::Synth::Patch; the distribution's doc/synthesis.md tells it whole. The synthesizer (Peta::Synth::Synth) asks a voice for its controls block by block and hands the voices to an engine, which turns them into samples; the fields an engine reads are listed at the top of the source.

METHODS

new

new($patch, key => ..., velocity => ..., rate => ..., partials => ..., start => ..., seed => ...). partials is the most partials the voice may have (the quality); the strongest of the patch's spectrum are kept.

release, kill

release($sample, $velocity): the key was let go at that sample (drums ignore it); the note-off velocity, where given, shortens (above 64) or lengthens the release. kill($sample): end within a few milliseconds.

controls

controls($now, $nb, $B, $channel): the voice's envelope, noise level, pitch and gains for a quantum of $nb blocks of $B samples starting at sample $now; $channel holds the channel's gains, bend and modulation at the blocks' edges (gl gr gs bend mod lv pn, arrays of $nb + 1; bend in semitones, mod in cents of vibrato, lv the level, pn the pan) and as single values vrate vdepth vdelay (factors on the patch's vibrato) and modrange (cents of vibrato at full pressure). Where GM2's controller destinations are set: dest, six arrays of $nb + 1 (pitch in semitones, cutoff in octaves, amplitude as a factor, the LFO's depth on pitch and cutoff in cents and on amplitude from 0 to 1), and kp, the same six at full key pressure (amplitude less 1), for the voice's own pressure.

pan_law

pan_law($pan): the left and right gains of a pan from -1 to 1.

bound, done, under, ends, envelope_at

bound($t): the loudest the voice can still get from a time on (seconds since it started); done($t): whether it is silent for good; under($t, $level): whether it has fallen under $level of its full level for good (past its attack); ends: when it will be silent for good (inf: never), as things stand; envelope_at($t): its envelope then (before the level and tremolo).

equalize

equalize($eq): a channel's equalizer (Peta::Synth::EQ) on the voice: each partial's level times the equalizer's gain at its frequency (a band of noise's at its centre, the string's at its pitch), from the levels it was made with, so that it can be applied again as the equalizer changes. Nothing is done where nothing would change.

off_velocity

off_velocity($velocity): a note-off velocity for a release to come: the release 1.41 times as long at 1, as the patch says at 64, 0.71 times at 127.

partials

How many partials the voice has.

FUNCTIONS

noise_table

The table of white noise every engine reads, the same on every perl.

filter_gain

filter_gain($x, $q, $mode): a filter's gain at $x (a frequency over the cutoff) and Q, by mode: what every engine computes for the edges of each partial.

AUTHOR

PetaMem s.r.o. <info@petamem.com>

COPYRIGHT

Copyright (c) 2026 PetaMem s.r.o.

LICENSE

This package is free software, dual-licensed under the Artistic License 2.0 and the BSD 2-Clause License. See the LICENSE file of the distribution.