NAME

Peta::Synth::Patch - the General MIDI instruments, their variations, and the drum kits

VERSION

version 0.2610180

SYNOPSIS

my $piano   = Peta::Synth::Patch::program(0);
my $detuned = Peta::Synth::Patch::program(4, 8);     # Detuned EP 1, GS bank 8
my $snare   = Peta::Synth::Patch::drum(38);
my $brush   = Peta::Synth::Patch::drum(38, 40);      # the brush kit's

DESCRIPTION

Every instrument is synthesized: a bank of sine partials and up to three bands of noise, under an envelope, with no samples. A patch is a hash of the fields listed (with their meaning and defaults) at the top of the source; the 128 General MIDI programs are built from family templates, and the drum keys 35 to 81 each have their own patch. Peta::Synth::Voice turns a patch and a note into the partials and envelope that the engines play.

A patch may have a string beside its partials, or instead of them (partials => []): a Karplus-Strong delay line, plucked or struck, its decay, damping, stiffness, pick position and pluck as the string fields say. So with FM: four sine operators in one of the eight algorithms of Yamaha's four-operator chips, operator 4 with feedback, each with its ratio, detune, level, envelope, velocity and key scaling (the fm and op fields).

Besides the spectrum, fixed when a note begins, a patch may have a filter that moves while the note sounds (low-pass of 12 or 24 dB an octave, high-pass, band-pass; its cutoff following the key, velocity and a second envelope, and brightness and resonance from CC74 and CC71), and routes of modulation: sources (velocity, key, the wheel, breath, foot, pressure, CC74, CC71, the second envelope, two LFOs) times an amount into destinations (pitch, cutoff, resonance, level, pan, noise).

FUNCTIONS

program

program($number, $bank): the patch of a GM program, 0 .. 127, or of its variation in GS's bank $bank (one of variations, below; dies otherwise).

drum

drum($key, $kit): the patch of a drum key in a kit (the standard kit, 0, unless told): the kit's own, or the standard kit's where the kit does not have the key as its own. Keys outside the GM kit get a short noise hit.

variation, kit, kit_key

variation($msb, $lsb, $program): the GS bank of the variation a bank select (MSB and LSB) picks for a program, 0 for the program itself: GS's banks as they are, GM2's (MSB 121) by their LSB where GM2's variation is one of GS's here; what is not here plays the program, as GS and XG do. kit($program): the kit a program change on a drum channel picks: the program's own, the first of its group of eight, or the standard kit, 0. kit_key($kit, $key): the kit whose patch the key plays in $kit.

The variations are those FluidR3 has (GS banks 8, 9 and 16), the kits Standard (0), Room (8), Power (16), Electronic (24), TR-808 (25), Jazz (32), Brush (40) and Orchestra (48).

fields, defaults

The names of a patch's fields; every field's default, as a hash.

field_info

The fields as an editor shows them: a list of hashes with name, group, min, max, scale (lin, log, int or choice, with its choices) and about.

mod_sources, mod_destinations, mod_info

The names of modulation's sources and destinations, and both with what they are.

program_name, drum_name, kit_name, program_names, drum_names, variations, kits

The names of the programs (program_name($number, $bank): a variation's with a bank), of the drum keys and of the kits; variations: every variation, as [ bank, program, name ]; kits: every kit, as { number => { name, keys } }, keys those it has as its own.

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.