NAME

Peta::Synth::Wavetable - partials compiled into wave sequences, made once and kept

VERSION

version 0.2610180

SYNOPSIS

my $waves = Peta::Synth::Wavetable->new;
my $copies = Peta::Synth::Wavetable::harmonics(\@ratio, \@amp, \@decay, \@attack) or return;   # not harmonic
my $sequence = $waves->sequence($copies->[0][1]);

DESCRIPTION

A voice whose partials are harmonics (each copy of its unison harmonics of its own fundamental) sounds the same read from tables of one period each: one for every moment where some partial has moved 3 dB (its decay, its fade-in), crossfaded from one to the next, the last held. Two tables read cost the same whatever the number of partials. A sequence is made once for what its partials are and kept; every voice with those partials reads it, from its own place in the period.

METHODS

new

A store of sequences.

sequence

sequence(\@partials) (each [harmonic, amplitude, decay, fade-in]): { size, times, tables }, made or found: size samples a period (at least 32 a period of the highest harmonic), times (seconds since the voice began), tables (size + 1 samples each, the last the first again).

stats

{ sequences, made, used, samples, seconds }: what is kept, how many were made and asked for, the samples in all the tables, the seconds spent making them.

FUNCTIONS

harmonics

harmonics(\@ratio, \@amp, \@decay, \@attack, $most) (a voice's partials, its unison's copies): [ [shift, [ [harmonic, amp, decay, attack], ... ]], ... ], a copy for each of the unison's (its fundamental over the voice's), or undef if they are not harmonics so.

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.