lib/Peta/Synth/Patch.pm

filter: Statementstmt 99.5% 208 / 209 Branchbran 85.7% 24 / 28 Conditioncond 66.6% 26 / 39 MC/DCmcdc 27.2% 6 / 22 Subroutinesub 95.8% 23 / 24 Podpod 100% 18 / 18 totaltotal 89.7% 305 / 340 CC 35 SCAR 13.8
CC
35
Cov
93%
program
7.6
program_name
6.4
kit_name
6.0
CRAP 4.0
« lib/Peta/Synth/FFT.pm ↑ Summary lib/Peta/MP3/Encode/Filterbank/PDL.pm »
1 package Peta::Synth::Patch;
2 # ABSTRACT: the General MIDI instruments, their variations, and the drum kits
3  
4 # The instruments: what a note of each General MIDI program and each drum
5 # key is made of, in the one voice model every engine plays; and the
6 # variations of programs and the drum kits that GS, GM2 and XG select by
7 # bank and program.
8 #
9 # A voice is a bank of sine partials and up to three bands of noise:
10 #
11 # partial k frequency f0 * ratio_k (times the pitch: bend, vibrato, sweep)
12 # amplitude amp_k * exp(-decay_k * t) * (1 - exp(-t / attack_k))
13 # noise white noise through a band-, high- or low-pass (centre Hz, q;
14 # two poles or four), its level rising over noise_attack and
15 # falling at noise_decay towards noise_sustain, steady or in
16 # bursts at random moments (grains); noise2 and noise3 the same;
17 # rough, noise moving the partials' amplitude
18 # envelope attack (linear), decay to sustain (exponential), release
19 # after the note's end (exponential): over the whole voice
20 #
21 # A patch describes the partials either as a spectrum (harmonics shaped by
22 # a slope, odd/even balance, formants, a low-pass, a pluck position, an
23 # inharmonicity) or as a list of explicit [ratio, amplitude, decay factor]
24 # partials, for bells, mallets and drums. Each GM program is a family's
25 # template with its own changes; the fields are documented with %DEFAULT.
26  
27 17 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 17 our $VERSION = '0.2610180';
30  
31 my %DEFAULT = (
32 # the harmonic spectrum
33 slope => 1.0, # amplitude of harmonic k: k ** -slope
34 even => 1.0, # even harmonics times this (0.1: clarinet-like; 1.5: an octave reed besides)
35 cutoff => 8000, # soft low-pass (Hz), 12 dB per octave above it
36 rolloff => 0, # ... and 12 more an octave for each one here (a hammer's felt: steeper)
37 track => 0.5, # the cutoff follows the key: (f0 / 261.6) ** track
38 bright => 1.0, # velocity opens the cutoff: 2 ** (bright * (v - 0.75) * 2)
39 pluck => 0, # pluck/strike position (0..0.5): harmonics with a node there are weak
40 formants => [], # [centre Hz, gain, width in octaves], added to the spectrum
41 stretch => 0, # inharmonicity B: harmonic k at k * sqrt(1 + B k^2)
42 stretch_key => 0, # B grows with the key: times 2 ** ((key - 60) / 12 * stretch_key)
43 partials => undef, # explicit [ratio, amplitude, decay factor] instead of the harmonic spectrum
44 max => 256, # harmonics at most
45  
46 # the partials over time
47 decay => 0, # 1/s, of the fundamental
48 decay_k => 0, # partial k decays (1 + decay_k (k - 1)) times faster
49 decay_key => 0, # and 2 ** ((key - 60) / 12 * decay_key) times faster with pitch
50 decay_k_key => 0, # decay_k grows with the key: times 2 ** ((key - 60) / 12 * decay_k_key) (a piano's treble)
51 attack_k => 0, # s: partial k fades in over attack_k * (k - 1) (brass speaks low first)
52  
53 # the whole voice
54 attack => 0.005,
55 hold => 0, # s at full level before the decay
56 fall => 1.0, # s: decay time constant towards sustain
57 sustain => 1.0,
58 release => 0.2, # s: time constant after the note's end (30 dB in 3.45 of them)
59 level => 1.0,
60 velocity => 1.6, # loudness: (velocity / 127) ** this
61  
62 # pitch
63 transpose => 0, # semitones
64 sweep => 0, # pitch starts sweep times higher (ratio - 1) ...
65 sweep_time => 0.05, # ... and falls back with this time constant
66 vibrato => 0, # cents
67 vib_rate => 5.5,
68 vib_delay => 0.3,
69 tremolo => 0, # amplitude modulation depth (0..1)
70 trem_rate => 5,
71 unison => 1, # copies of the partials, detuned
72 detune => 0, # cents between the outermost copies
73 unison_k => 8, # the copies carry this many partials
74 unison_sync => 0, # 1: the copies begin in phase (strings struck by one hammer)
75  
76 # noise
77 noise => 0,
78 noise_center => 3000, # Hz; with noise_ratio, times f0 instead
79 noise_ratio => 0,
80 noise_q => 1.0,
81 noise_attack => 0.001,
82 noise_decay => 30, # 1/s
83 noise_sustain => 0, # level that is left (breath)
84 noise_mode => 'band', # band, high or low (-pass)
85 noise_poles => 2, # 2: 12 dB an octave (band-pass 6), 4: twice that
86 noise_grains => 0, # bursts a second at random moments (applause, rain); 0: steady
87 noise_grain_decay => 150, # how fast a burst falls (1/s)
88 # a second and a third band, the same fields
89 _band_defaults('noise2'),
90 _band_defaults('noise3'),
91 # a plucked or struck string (Karplus-Strong): a delay line a period
92 # long, its loop damped and decaying, started with a pluck or a
93 # hammer's blow; beside the partials (give the patch partials => [] for
94 # a string alone)
95 string => 0, # its level
96 string_decay => 4, # s it takes to fall 60 dB, at middle C
97 string_key => 0.5, # higher keys decay faster: (261.6 / f0) ** this
98 string_damp => 0.3, # the loop's low-pass (0: none; more: the highs die sooner)
99 string_pick => 0.13, # where along the string it is plucked or struck (0 .. 0.5)
100 string_bright => 0.5, # how bright the pluck is (0 .. 1)
101 string_vel => 1, # how much velocity brightens it
102 string_noise => 0.25, # how much of the pluck is noise (the rest the string's shape)
103 string_excite => 'pluck', # pluck or strike (a hammer: string_bright its hardness)
104 string_stiff => 0, # stiffness, as stretch: harmonic k at k * sqrt(1 + B k^2)
105  
106 # FM: four sine operators, each modulated by the sum of others' outputs
107 # as the algorithm (1 .. 8, those of Yamaha's four-operator chips) says;
108 # operator 4 also by itself (feedback). A carrier's level is its
109 # amplitude, a modulator's the index it modulates with (radians). Beside
110 # the partials, or alone (partials => []).
111 fm => 0, # the FM's level
112 fm_alg => 1,
113 fm_fb => 0, # operator 4's feedback (0 .. 1: up to pi)
114 17 (map { _operator_defaults($_) } 1 .. 4),
115  
116 # noise on the partials: their amplitude moved by noise low-passed at
117 # rough_rate, rough its depth (breath, bow, growl)
118 rough => 0,
119 rough_rate => 200, # Hz
120  
121 # the filter that moves: over the partials, its cutoff and resonance
122 # modulated while the note sounds (the spectrum's cutoff above is fixed
123 # when the note begins)
124 filter => 'off', # off lp12 lp24 hp12 hp24 bp
125 filter_cutoff => 2000, # Hz, at middle C
126 filter_track => 1, # how much the cutoff follows the key
127 filter_q => 0.71, # resonance
128 filter_env => 0, # octaves the second envelope moves the cutoff, at its peak
129 filter_vel => 0, # octaves velocity moves it (from 0.75 of the full velocity)
130  
131 # the second envelope (a source of modulation): attack (linear), decay
132 # (time constant) to sustain, release (time constant)
133 env2_attack => 0.01,
134 env2_decay => 0.3,
135 env2_sustain => 0,
136 env2_release => 0.3,
137  
138 # two LFOs (sources of modulation), from the note's start
139 lfo1_rate => 5, # Hz
140 lfo1_shape => 'sine', # sine triangle square saw random
141 lfo1_delay => 0, # s it fades in over
142 lfo2_rate => 0.5,
143 lfo2_shape => 'triangle',
144 lfo2_delay => 0,
145  
146 # routes: [source, destination, amount]; see mod_sources, mod_destinations
147 mods => [],
148  
149 drum => 0,
150 fixed => 0, # Hz: a drum sounds at this pitch whatever the key
151 length => 0, # s: a drum that ignores note off rings this long at most
152 );
153  
154 # The defaults of a noise band's fields, $band its name.
155 34 ▶sub _band_defaults ($band) {
Subroutine _band_defaults: called CC=1 SCAR=0.0
156 return (
157 34 $band => 0,
158 "${band}_center" => 3000,
159 "${band}_ratio" => 0,
160 "${band}_q" => 1.0,
161 "${band}_attack" => 0.001,
162 "${band}_decay" => 30,
163 "${band}_sustain" => 0,
164 "${band}_mode" => 'band',
165 "${band}_poles" => 2,
166 "${band}_grains" => 0,
167 "${band}_grain_decay" => 150,
168 );
169 }
170  
171 # The defaults of FM operator $o's fields: operators 1 and 2 sound, 3 and 4
172 # are silent.
173 68 ▶sub _operator_defaults ($o) {
Subroutine _operator_defaults: called CC=2 SCAR=6.9
174 return (
175 68 ▶ "op${o}_ratio" => 1,
Branch: 1 branch
BranchTrueFalseTotal
$o <= 2 ? : 34 34 68
176 "op${o}_detune" => 0,
177 "op${o}_level" => $o <= 2 ? 1 : 0,
178 "op${o}_attack" => 0.002,
179 "op${o}_decay" => 1,
180 "op${o}_sustain" => 1,
181 "op${o}_release" => 0.3,
182 "op${o}_vel" => 0.5,
183 "op${o}_key" => 0,
184 );
185 }
186  
187 # Modulation: its sources (with their ranges), its destinations (with what
188 # an amount of 1 does). Bipolar sources swing -1 .. 1, the others 0 .. 1.
189 17 my @MOD_SOURCES = (
190 [ velocity => 'the note\'s velocity, 0 .. 1' ],
191 [ key => 'the key, in octaves from middle C' ],
192 [ wheel => 'the modulation wheel (CC1)' ],
193 [ breath => 'the breath controller (CC2)' ],
194 [ foot => 'the foot controller (CC4)' ],
195 [ pressure => 'channel or key pressure, the greater' ],
196 [ cc74 => 'brightness (CC74), -1 .. 1 around 64' ],
197 [ cc71 => 'resonance (CC71), -1 .. 1 around 64' ],
198 [ env2 => 'the second envelope, 0 .. 1' ],
199 [ lfo1 => 'the first LFO, -1 .. 1' ],
200 [ lfo2 => 'the second LFO, -1 .. 1' ],
201 );
202 17 my @MOD_DESTINATIONS = (
203 [ pitch => 'semitones' ],
204 [ cutoff => 'octaves of the filter\'s cutoff' ],
205 [ q => 'octaves of the filter\'s resonance (Q times 2^amount)' ],
206 [ level => 'the level, times 1 + amount' ],
207 [ pan => 'the pan, -1 left .. 1 right' ],
208 [ noise => 'the noise\'s level, times 1 + amount' ],
209 [ fm => 'octaves of FM\'s modulation index (its modulators\' levels times 2^amount)' ],
210 );
211 19 ▶sub mod_sources () { return [ map { $_->[0] } @MOD_SOURCES ] }
Subroutine mod_sources: called CC=1 SCAR=0.0
Pod documented
212 19 ▶sub mod_destinations () { return [ map { $_->[0] } @MOD_DESTINATIONS ] }
Subroutine mod_destinations: called CC=1 SCAR=0.0
Pod documented
213 4 ▶sub mod_info () {
Subroutine mod_info: called CC=1 SCAR=0.0
Pod documented
214 return {
215 44 sources => [ map { { name => $_->[0], about => $_->[1] } } @MOD_SOURCES ],
216 4 destinations => [ map { { name => $_->[0], about => $_->[1] } } @MOD_DESTINATIONS ],
217 };
218 }
219  
220 517 ▶sub _make (%arg) {
Subroutine _make: called CC=3 SCAR=11.1
221 517 my %patch = (%DEFAULT, %arg);
222 517 ▶ for my $key (keys %arg) { die "patch field '$key' is not known\n" unless exists $DEFAULT{$key} }
Branch: 1 branch
BranchTrueFalseTotal
unless exists $DEFAULT{$key} 0 7787 7787
223 517 return \%patch;
224 }
225  
226 # Families: the templates the programs start from.
227  
228 # The piano, measured against a recorded grand (FluidR3, with
229 # bin/peta-analyze): the fundamental strongest, the harmonics as 1/k up to
230 # some 4 kHz, falling 24 dB an octave above, whatever the key (the hammer's
231 # felt; less, and the highs ring on as a harpsichord's); the strings stiffer
232 # up the keyboard (B 0.0003 at middle C, twice that an octave up); a quick
233 # fall (fall, sustain) before the slow decay; the upper partials dying
234 # sooner, the more so up the keyboard (decay_k_key: at C6 the 5th some 40
235 # dB a second); the two strings of a note struck together (unison_sync),
236 # beating in the lower partials.
237 17 my %PIANO = (slope => 1.0, cutoff => 4000, rolloff => 1, track => 0, bright => 1.6, stretch => 0.0003, stretch_key => 1.1,
238 decay => 0.5, decay_key => 0.5, decay_k => 0.1, decay_k_key => 1.25, attack => 0.002, fall => 0.45, sustain => 0.3,
239 release => 0.14, unison => 2, detune => 1.5, unison_k => 8, unison_sync => 1,
240 noise => 0.05, noise_center => 1800, noise_q => 0.8, noise_decay => 45, level => 0.9);
241 # The first pass's piano, which the electric grand, the harpsichord and the
242 # clavinet are made from.
243 17 my %KEYBOARD = (slope => 0.9, cutoff => 2600, track => 0.6, bright => 1.6, pluck => 0.12, stretch => 0.0004,
244 decay => 0.45, decay_k => 0.35, decay_key => 0.9, attack => 0.002, sustain => 1, release => 0.14,
245 unison => 2, detune => 1.2, unison_k => 10,
246 noise => 0.05, noise_center => 1800, noise_q => 0.8, noise_decay => 45, level => 0.9);
247 # The tine piano, after a recorded one (FluidR3): the fundamental sustains
248 # (some 2 dB a second), the 2nd and 3rd harmonics strong, the tine's clang short.
249 17 my %EPIANO = (partials => [ [1, 1, 1], [2, 0.6, 2], [3, 0.42, 2.8], [4, 0.07, 4], [5, 0.14, 5], [7.06, 0.06, 20] ],
250 decay => 0.25, attack => 0.002, release => 0.18, bright => 1.2, tremolo => 0.15, trem_rate => 4.5, level => 0.9);
251 17 my %MALLET = (decay => 3.0, decay_key => 0.6, attack => 0.0015, release => 0.4, bright => 0.8);
252 17 my %ORGAN = (partials => [ [0.5, 0.6, 1], [1, 1, 1], [1.5, 0.45, 1], [2, 0.7, 1], [3, 0.4, 1], [4, 0.45, 1],
253 [5, 0.15, 1], [6, 0.2, 1], [8, 0.25, 1] ],
254 attack => 0.008, release => 0.025, vibrato => 6, vib_rate => 6.7, vib_delay => 0, velocity => 0.5,
255 noise => 0.04, noise_center => 4000, noise_decay => 80, level => 0.6);
256 17 my %GUITAR = (slope => 1.0, cutoff => 3500, bright => 1.2, pluck => 0.14, stretch => 0.00003,
257 decay => 0.9, decay_k => 0.55, decay_key => 0.6, attack => 0.002, release => 0.12,
258 noise => 0.04, noise_center => 2500, noise_decay => 80, level => 0.9);
259 17 my %BASS = (slope => 1.2, cutoff => 1200, track => 0.3, bright => 1.2, pluck => 0.2,
260 decay => 0.7, decay_k => 0.5, attack => 0.004, release => 0.08, max => 40, level => 1.1);
261 17 my %STRINGS = (slope => 1.0, cutoff => 3200, track => 0.4, bright => 0.8,
262 formants => [ [280, 0.8, 0.6], [1100, 0.5, 0.7], [2600, 0.6, 0.5] ],
263 attack => 0.09, fall => 1.5, sustain => 0.9, release => 0.06, vibrato => 12, vib_rate => 5.6, vib_delay => 0.25,
264 noise => 0.015, noise_ratio => 3, noise_q => 2, noise_decay => 0, noise_sustain => 1, level => 0.8);
265 # The solo strings each have their body's resonances (measured against
266 # FluidR3 across their range, bin/peta-analyze --response): the harmonics
267 # below its lowest mode weak (the violin's G string's fundamental), peaks
268 # and dips fixed in Hz, the fall above them.
269 17 my %ENSEMBLE = (%STRINGS, attack => 0.25, release => 0.15, unison => 3, detune => 14, unison_k => 16, vibrato => 6,
270 level => 0.7);
271 # The voices, after recorded ones (FluidR3): the vowel's first formant
272 # strongest, the second weaker, the singer's formant near 3 kHz; the
273 # fundamental of the low notes weak; the breath low-passed.
274 17 my %CHOIR = (slope => 1.3, cutoff => 3000, track => 0.2, bright => 0.4,
275 formants => [ [130, -0.8, 0.5], [650, 4, 0.4], [1100, 1, 0.3], [2900, 1.5, 0.3] ],
276 attack => 0.2, release => 0.2, vibrato => 10, vib_rate => 5, vib_delay => 0.3,
277 unison => 3, detune => 10, unison_k => 24, noise => 0.02, noise_center => 2500, noise_mode => 'low', noise_decay => 0,
278 noise_sustain => 1,
279 level => 0.6);
280 17 my %BRASS = (slope => 0.75, cutoff => 1500, track => 0.5, bright => 2.4, attack => 0.035, attack_k => 0.006,
281 fall => 0.6, sustain => 0.85, release => 0.035, vibrato => 6, vib_delay => 0.4,
282 noise => 0.02, noise_center => 1500, noise_decay => 25, level => 0.75);
283 # The reeds (saxophones, double reeds, clarinet), after recorded ones
284 # (FluidR3, measured across their ranges with bin/peta-analyze --response):
285 # a source of harmonics 1/k through the bore and bell, its resonances fixed
286 # in Hz (the formants) and a steep fall above them; the breath low-passed.
287 17 my %REED = (slope => 1.0, cutoff => 3000, rolloff => 2, track => 0, bright => 1.0, attack => 0.03, release => 0.03,
288 vibrato => 10, vib_rate => 5.2, vib_delay => 0.3,
289 noise => 0.02, noise_ratio => 4, noise_mode => 'low', noise_decay => 0, noise_sustain => 1, level => 0.75);
290 # The free reeds (reed organ, accordion, harmonica), after recorded ones
291 # (FluidR3): the harmonics nearly level up to the 6th or 7th, falling
292 # steeply above, at every key (the low-pass follows it); steady, no vibrato.
293 17 my %FREE_REED = (slope => 0.3, cutoff => 2000, track => 1, rolloff => 1, bright => 0.5, attack => 0.03, release => 0.035,
294 noise => 0.015, noise_ratio => 4, noise_q => 1.5, noise_decay => 0, noise_sustain => 1, level => 0.6);
295 # The flutes, after recorded ones (FluidR3): the 2nd harmonic near the
296 # fundamental, falling from some 1.5 kHz at middle C; a little breath, in a
297 # narrow band (a state-variable band falls only 6 dB an octave: wide or
298 # loud, it hisses up to the top).
299 17 my %PIPE = (slope => 1.0, cutoff => 1500, bright => 1.0, attack => 0.06, release => 0.04,
300 vibrato => 8, vib_rate => 5, vib_delay => 0.35,
301 noise => 0.03, noise_ratio => 2, noise_q => 2, noise_decay => 8, noise_sustain => 0.4, level => 0.8);
302 17 my %LEAD = (slope => 1.0, cutoff => 7000, track => 0.3, bright => 1.0, attack => 0.004, release => 0.032,
303 vibrato => 8, vib_rate => 5.5, vib_delay => 0.4, level => 0.55);
304 17 my %PAD = (slope => 1.0, cutoff => 1400, track => 0.3, bright => 0.5, attack => 0.5, fall => 2, sustain => 0.9,
305 release => 0.8, unison => 3, detune => 16, unison_k => 24, level => 0.55);
306 17 my %BELL = (decay => 0.7, decay_key => 0.4, attack => 0.001, release => 1.2, bright => 0.6);
307  
308 my @GM = (
309 # Piano
310 # 0 Acoustic Grand
311 { %PIANO },
312 # 1 Bright Acoustic
313 { %PIANO, cutoff => 5500, slope => 0.85 },
314 # 2 Electric Grand
315 { %KEYBOARD, cutoff => 3200, decay => 0.6, unison => 2, detune => 4 },
316 # 3 Honky-tonk (out of tune, not wah-wah)
317 { %PIANO, unison => 3, detune => 7, unison_sync => 0, cutoff => 3200 },
318 # 4 Electric Piano 1 (tines)
319 { %EPIANO },
320 # 5 Electric Piano 2 (FM-ish)
321 { %EPIANO, partials => [ [1, 1, 1], [2, 0.6, 1.5], [3, 0.45, 2], [4, 0.35, 2.5], [5, 0.25, 3], [6, 0.18, 3.5],
322 [7, 0.1, 4], [8, 0.08, 4.5] ], decay => 0.3, tremolo => 0 },
323 # 6 Harpsichord: the quill's bright pluck
324 { %KEYBOARD, slope => 0.35, pluck => 0.08, cutoff => 9000, track => 0, bright => 0.6, stretch => 0.00005, unison => 2,
325 detune => 3, decay => 0.8, decay_k => 0.12, level => 0.6 },
326 # 7 Clavinet
327 { %KEYBOARD, slope => 0.55, even => 0.5, cutoff => 4000, pluck => 0.1, unison => 1, decay => 1.2, level => 0.7 },
328  
329 # Chromatic percussion
330 # 8 Celesta
331 { %BELL, partials => [ [1, 1, 1], [3, 0.4, 2], [4.06, 0.2, 3], [6.98, 0.1, 4] ], decay => 0.9 },
332 # 9 Glockenspiel
333 { %BELL, partials => [ [1, 1, 1], [2.71, 0.35, 2.5], [5.15, 0.15, 4], [8.43, 0.06, 6] ],
334 decay => 1.2, fall => 0.12, sustain => 0.15, bright => 0.4, transpose => 12 },
335 # 10 Music Box
336 { %BELL, partials => [ [1, 1, 1], [4.08, 0.3, 2], [10.2, 0.08, 3] ], decay => 1.6, release => 0.5 },
337 # 11 Vibraphone
338 { %MALLET, partials => [ [1, 1, 1], [4, 0.3, 1.8], [10.1, 0.08, 3] ], decay => 0.55, tremolo => 0.3,
339 trem_rate => 5.5, release => 0.6 },
340 # 12 Marimba
341 { %MALLET, partials => [ [1, 1, 1], [3.99, 0.35, 2.5], [9.9, 0.1, 5] ], decay => 2.8 },
342 # 13 Xylophone
343 { %MALLET, partials => [ [1, 1, 1], [3, 0.4, 2], [6.0, 0.15, 3] ], decay => 4, transpose => 12 },
344 # 14 Tubular Bells
345 { %BELL, partials => [ [0.5, 0.2, 0.6], [1, 1, 1], [2.76, 0.6, 1.4], [5.4, 0.4, 2], [8.93, 0.25, 2.5],
346 [13.34, 0.1, 3] ], decay => 0.4, noise => 0.03 },
347 # 15 Dulcimer: hammered, its courses ringing on
348 { %GUITAR, slope => 0.45, pluck => 0.1, cutoff => 7000, decay => 0.35, decay_k => 0.3, fall => 0.2, sustain => 0.12,
349 unison => 3, detune => 4, unison_k => 16, release => 0.5 },
350  
351 # Organ
352 # 16 Drawbar
353 { %ORGAN },
354 # 17 Percussive: the third falls
355 { %ORGAN, noise => 0.08, decay => 5, partials => [ [1, 1, 0], [2, 0.6, 0], [3, 1.6, 1], [4, 0.3, 0], [6, 0.2, 0] ] },
356 # 18 Rock
357 { %ORGAN, partials => [ [0.5, 0.5, 1], [1, 1, 1], [1.5, 0.6, 1], [2, 0.8, 1], [3, 0.6, 1], [4, 0.6, 1],
358 [5, 0.4, 1], [6, 0.4, 1], [8, 0.5, 1] ], vibrato => 14 },
359 # 19 Church: a principal chorus, its pipes in tune
360 { partials => [ [1, 1, 0], [2, 0.75, 0], [3, 0.45, 0], [4, 0.6, 0], [5, 0.15, 0], [6, 0.4, 0], [8, 0.5, 0],
361 [10, 0.2, 0], [12, 0.35, 0], [16, 0.3, 0], [20, 0.12, 0], [24, 0.15, 0] ],
362 attack => 0.07, release => 0.2, level => 0.55,
363 noise => 0.05, noise_ratio => 2, noise_q => 2, noise_decay => 12, noise_sustain => 0.1 },
364 # 20 Reed Organ
365 { %FREE_REED, slope => 0.5, cutoff => 2400, attack => 0.05, release => 0.04, level => 0.6 },
366 # 21 Accordion: musette, a reed in tune, one sharp, one flat
367 { %FREE_REED, cutoff => 3000, attack_k => 0.008, unison => 3, detune => 36, unison_k => 12 },
368 # 22 Harmonica
369 { %FREE_REED, slope => 0.6, cutoff => 3200, vibrato => 12, vib_rate => 5.2, vib_delay => 0.3,
370 noise => 0.03 },
371 # 23 Tango Accordion: dry, reeds in octaves (the bandoneon)
372 { %FREE_REED, slope => 0.85, even => 1.5, cutoff => 4000 },
373  
374 # Guitar
375 # 24 Nylon
376 { %GUITAR, slope => 1.3, cutoff => 2400 },
377 # 25 Steel
378 { %GUITAR },
379 # 26 Jazz
380 { %GUITAR, cutoff => 3000, decay => 0.5, decay_k => 0.4, pluck => 0.2, level => 0.85 },
381 # 27 Clean
382 { %GUITAR, cutoff => 4500, decay => 0.5, decay_k => 0.35, pluck => 0.1 },
383 # 28 Muted
384 { %GUITAR, cutoff => 2500, decay => 6, decay_k => 0.2, release => 0.04 },
385 # 29 Overdriven
386 { %GUITAR, slope => 0.6, cutoff => 2800, track => 0, decay => 0.15, decay_k => 0.1, sustain => 1,
387 unison => 2, detune => 8, formants => [ [1200, 1.5, 0.8] ], level => 0.6 },
388 # 30 Distortion
389 { %GUITAR, slope => 0.5, cutoff => 3000, track => 0, decay => 0.1, decay_k => 0.08, sustain => 1,
390 unison => 3, detune => 14, formants => [ [900, 2, 0.8], [2400, 1.5, 0.5] ], level => 0.55 },
391 # 31 Harmonics
392 { %BELL, partials => [ [1, 1, 1], [2, 0.6, 1.2], [3, 0.4, 1.4], [4, 0.3, 1.6] ], decay => 0.8,
393 transpose => 12, level => 0.6 },
394  
395 # Bass
396 # 32 Acoustic
397 { %BASS, slope => 1.5, decay => 1.0, decay_k => 0.4, pluck => 0.15 },
398 # 33 Finger
399 { %BASS },
400 # 34 Pick
401 { %BASS, slope => 1.0, cutoff => 1800, pluck => 0.1, decay_k => 0.6 },
402 # 35 Fretless
403 { %BASS, slope => 1.6, cutoff => 900, vibrato => 6, vib_delay => 0.4 },
404 # 36 Slap 1
405 { %BASS, slope => 0.8, cutoff => 2500, pluck => 0.06, decay => 1.2, decay_k => 0.8 },
406 # 37 Slap 2
407 { %BASS, slope => 0.8, cutoff => 2800, pluck => 0.06, decay => 1.2, decay_k => 0.8 },
408 # 38 Synth Bass 1
409 { %BASS, slope => 1.0, cutoff => 900, pluck => 0, decay => 0.3, decay_k => 1.5, sustain => 1 },
410 # 39 Synth Bass 2
411 { %BASS, slope => 1.0, cutoff => 1300, pluck => 0, decay => 0.2, decay_k => 0.8, unison => 2, detune => 10 },
412  
413 # Strings
414 # 40 Violin
415 { %STRINGS, cutoff => 4000, track => 0, vib_rate => 6, attack => 0.08,
416 formants => [ [210, -0.93, 0.6], [450, 0.6, 0.5], [1600, -0.3, 0.6] ] },
417 # 41 Viola
418 { %STRINGS, cutoff => 3800, track => 0, vib_rate => 5.6, attack => 0.09,
419 formants => [ [130, -0.95, 0.45], [450, 0.25, 0.6], [900, -0.35, 0.3] ] },
420 # 42 Cello
421 { %STRINGS, cutoff => 2800, track => 0, vib_rate => 5.3, attack => 0.1,
422 formants => [ [62, -0.8, 0.25], [80, -0.95, 0.4], [225, 0.35, 0.4], [400, -0.35, 0.25], [630, 0.6, 0.2],
423 [1100, -0.55, 0.35] ] },
424 # 43 Contrabass
425 { %STRINGS, cutoff => 1600, track => 0, vib_rate => 4.8, attack => 0.13,
426 formants => [ [40, -0.95, 0.3], [52, -0.97, 0.3], [150, -0.35, 0.4], [250, -0.8, 0.25], [700, -0.75, 1] ] },
427 # 44 Tremolo
428 { %ENSEMBLE, tremolo => 0.5, trem_rate => 11 },
429 # 45 Pizzicato
430 { %GUITAR, slope => 1.2, cutoff => 2000, decay => 5, pluck => 0.25, release => 0.1 },
431 # 46 Harp
432 { %GUITAR, slope => 1.4, cutoff => 3000, decay => 0.5, decay_k => 0.35, pluck => 0.18, release => 0.5 },
433 # 47 Timpani
434 { sweep => 0.15, sweep_time => 0.04, partials => [ [1, 1, 1], [1.5, 0.3, 2], [2.0, 0.25, 2], [2.8, 0.12, 3] ],
435 decay => 1.0, attack => 0.002, release => 0.3, noise => 0.2, noise_center => 300, noise_decay => 15 },
436  
437 # Ensemble
438 # 48 Strings
439 { %ENSEMBLE },
440 # 49 Slow Strings
441 { %ENSEMBLE, attack => 0.5, cutoff => 2400 },
442 # 50 Synth Strings 1
443 { %PAD, slope => 0.9, cutoff => 2600, attack => 0.15, release => 0.4 },
444 # 51 Synth Strings 2
445 { %PAD, slope => 0.9, cutoff => 2000, attack => 0.3 },
446 # 52 Choir Aahs
447 { %CHOIR },
448 # 53 Voice Oohs: near the fundamental alone
449 { %CHOIR, slope => 2, formants => [ [300, 3, 0.35], [870, 0.8, 0.3], [2240, 0.3, 0.25] ], unison => 1,
450 release => 0.1 },
451 # 54 Synth Voice
452 { %CHOIR, slope => 1.2, formants => [ [500, 2, 0.4], [1500, 1, 0.4] ], cutoff => 4000, attack => 0.08 },
453 # 55 Orchestra Hit: a stab, the octave under it and the fifth
454 { %ENSEMBLE, transpose => -12, even => 1.6, attack => 0.01, fall => 0.25, sustain => 0, release => 0.3 },
455  
456 # Brass
457 # (Measured against FluidR3: the bell radiates the low harmonics weakly, a
458 # dip fixed in Hz under each instrument's lowest notes.)
459 # 56 Trumpet
460 { %BRASS, cutoff => 2200, formants => [ [250, -0.7, 0.7] ] },
461 # 57 Trombone
462 { %BRASS, cutoff => 1400, formants => [ [110, -0.8, 0.5], [500, 1, 0.6] ] },
463 # 58 Tuba: its first harmonics
464 { %BRASS, cutoff => 400, track => 0, rolloff => 1 },
465 # 59 Muted Trumpet: the harmon mute, bright and thin
466 { %BRASS, slope => 0.75, cutoff => 6000, track => 0, bright => 1.2,
467 formants => [ [350, -0.85, 0.8], [2500, 2, 0.8] ] },
468 # 60 French Horn
469 { %BRASS, slope => 1.3, cutoff => 1300, attack => 0.1, release => 0.05, formants => [ [110, -0.8, 0.5] ] },
470 # 61 Brass Section: forte, bright
471 { %BRASS, unison => 3, detune => 12, cutoff => 3500, attack => 0.08, release => 0.05, level => 0.6,
472 formants => [ [150, -0.8, 0.6] ] },
473 # 62 Synth Brass 1
474 { %BRASS, unison => 2, detune => 10, slope => 0.9, attack => 0.01, attack_k => 0, vibrato => 0 },
475 # 63 Synth Brass 2
476 { %BRASS, unison => 2, detune => 14, slope => 1.0, cutoff => 1100, attack => 0.015, attack_k => 0, vibrato => 0 },
477  
478 # Reed
479 # 64 Soprano Sax: rising to 2.5 kHz
480 { %REED, cutoff => 3400, formants => [ [250, -0.65, 0.8] ] },
481 # 65 Alto Sax
482 { %REED, cutoff => 3200, formants => [ [130, -0.95, 0.4], [700, 1.5, 0.4], [1600, -0.6, 0.2], [2100, 1, 0.25] ] },
483 # 66 Tenor Sax
484 { %REED, cutoff => 3000, formants => [ [110, -0.9, 0.5], [630, 1.2, 0.25], [900, -0.3, 0.3], [1700, 1.2, 0.5] ] },
485 # 67 Baritone Sax
486 { %REED, cutoff => 3800, formants => [ [75, -0.95, 0.5], [1700, 0.8, 0.6] ] },
487 # 68 Oboe: a peak at 1.25 kHz over a weak fundamental
488 { %REED, attack => 0.08, formants => [ [1250, 4, 0.35], [2800, 1, 0.4] ] },
489 # 69 English Horn: a narrow peak at 1 kHz
490 { %REED, cutoff => 2500, rolloff => 0, attack => 0.08, formants => [ [200, -0.6, 0.6], [1000, 4, 0.2] ] },
491 # 70 Bassoon: its formant at 480 Hz
492 { %REED, cutoff => 1600, rolloff => 1, vibrato => 0,
493 formants => [ [65, -0.9, 0.3], [150, -0.7, 0.7], [480, 6, 0.3], [1200, 0.6, 0.5] ] },
494 # 71 Clarinet: odd harmonics, strongest at 2 kHz, none past 5
495 { %REED, even => 0.02, cutoff => 4000, rolloff => 3, vibrato => 0, release => 0.02,
496 formants => [ [2000, 2.5, 0.6] ] },
497  
498 # Pipe
499 # 72 Piccolo
500 { %PIPE, cutoff => 2000, transpose => 12 },
501 # 73 Flute
502 { %PIPE },
503 # 74 Recorder: purer up the keyboard
504 { %PIPE, slope => 1.4, even => 0.3, cutoff => 1800, rolloff => 1, track => 0 },
505 # 75 Pan Flute
506 { %PIPE, slope => 1.8, attack => 0.1, noise => 0.03, noise_ratio => 4, noise_mode => 'low', noise_sustain => 0.8 },
507 # 76 Blown Bottle: the fundamental, breath under 1.5 kHz
508 { %PIPE, slope => 4, even => 0.15, noise => 0.04, noise_ratio => 0, noise_center => 1500, noise_mode => 'low',
509 noise_sustain => 1 },
510 # 77 Shakuhachi
511 { %PIPE, slope => 2.6, cutoff => 2500, noise => 0.1, noise_ratio => 4, noise_mode => 'low', attack => 0.08 },
512 # 78 Whistle
513 { slope => 9, attack => 0.05, release => 0.06, vibrato => 15, vib_rate => 6, vib_delay => 0.1, level => 0.8 },
514 # 79 Ocarina: nearly odd harmonics only
515 { %PIPE, slope => 2.0, even => 0.02, cutoff => 2000, noise => 0.02 },
516  
517 # Synth lead
518 # 80 Square
519 { %LEAD, even => 0.05 },
520 # 81 Sawtooth
521 { %LEAD },
522 # 82 Calliope: a flute's, breathy, wavering
523 { %LEAD, slope => 2.4, noise => 0.03, noise_ratio => 4, noise_mode => 'low', noise_decay => 0, noise_sustain => 1,
524 vibrato => 20, vib_delay => 0.2 },
525 # 83 Chiff
526 { %LEAD, slope => 1.8, noise => 0.4, noise_decay => 40 },
527 # 84 Charang
528 { %GUITAR, %LEAD, decay => 0.2, decay_k => 0.2, cutoff => 6000, pluck => 0.1, unison => 2, detune => 8 },
529 # 85 Voice
530 { %CHOIR, slope => 1.4, formants => [ [400, 2, 0.4], [1200, 0.8, 0.4] ], unison => 1, attack => 0.15, release => 0.13,
531 vibrato => 20, vib_delay => 0.15 },
532 # 86 Fifths
533 272 { %LEAD, partials => [ map { ([ $_, 1 / $_, 1 ], [ 1.5 * $_, 0.6 / $_, 1 ]) } 1 .. 16 ], level => 0.25 },
534 # 87 Bass + Lead
535 { %LEAD, unison => 2, detune => 8, cutoff => 5000, release => 0.01, level => 0.6 },
536  
537 # Synth pad
538 # 88 New Age: struck, then the pad
539 { %PAD, slope => 1.2, cutoff => 2200, attack => 0.02, fall => 1.2, sustain => 0.5, decay_k => 0.6, decay => 0.05 },
540 # 89 Warm
541 { %PAD },
542 # 90 Polysynth
543 { %PAD, cutoff => 3000, attack => 0.2, decay_k => 0.4, decay => 0.15, sustain => 0.9 },
544 # 91 Choir
545 { %CHOIR, slope => 1.2, attack => 0.1, release => 1.0 },
546 # 92 Bowed
547 { %PAD, slope => 1.5, cutoff => 4000, attack => 0.15, tremolo => 0.2, trem_rate => 3 },
548 # 93 Metallic
549 { %PAD, slope => 0.9, even => 0.4, cutoff => 2600, attack => 0.2 },
550 # 94 Halo
551 { %PAD, cutoff => 3500, attack => 0.4, formants => [ [600, 3, 0.4], [1200, 2, 0.4] ] },
552 # 95 Sweep: a resonant low-pass opening and closing
553 { %PAD, cutoff => 6000, attack => 0.8, filter => 'lp24', filter_cutoff => 400, filter_q => 2, filter_env => 4,
554 env2_attack => 2, env2_decay => 3, env2_sustain => 0.3, env2_release => 1 },
555  
556 # Synth effects
557 # 96 Rain
558 { %BELL, partials => [ [1, 1, 1], [2.4, 0.4, 2], [5.3, 0.2, 3] ], decay => 0.6, noise => 0.04,
559 noise_center => 6000, noise_q => 2, noise_decay => 5 },
560 # 97 Soundtrack
561 { %PAD, attack => 0.4, cutoff => 2800, unison => 3, detune => 22 },
562 # 98 Crystal
563 { %BELL, partials => [ [1, 1, 1], [2.76, 0.5, 1.3], [5.4, 0.35, 1.8], [8.9, 0.2, 2.2], [12.6, 0.15, 2.6] ],
564 decay => 1.5 },
565 # 99 Atmosphere
566 { %PAD, %BELL, partials => undef, slope => 1.2, decay => 0.4, decay_k => 0.2, release => 1.5 },
567 # 100 Brightness
568 { %PAD, slope => 0.8, cutoff => 5000, attack => 0.1 },
569 # 101 Goblins
570 { %PAD, attack => 1.0, vibrato => 30, vib_rate => 1.5, vib_delay => 0 },
571 # 102 Echoes: repeating
572 17 { %BELL, decay => 0.3, partials => [ map { [ $_, 1 / $_, 1 + $_ / 4 ] } 1 .. 8 ], attack => 0.05, release => 1.5,
573 tremolo => 0.4, trem_rate => 5 },
574 # 103 Sci-Fi: a resonance closing
575 { %PAD, slope => 0.9, cutoff => 6000, vibrato => 40, vib_rate => 0.5, vib_delay => 0, filter => 'lp24',
576 filter_cutoff => 3000, filter_q => 6, filter_env => -3, env2_attack => 0.01, env2_decay => 1.5, env2_sustain => 0.3 },
577  
578 # Ethnic
579 # 104 Sitar
580 { %GUITAR, slope => 0.6, cutoff => 5000, pluck => 0.05, decay => 0.6, decay_k => 0.25, release => 1,
581 formants => [ [2500, 3, 0.6] ], sweep => 0.01, sweep_time => 0.2 },
582 # 105 Banjo: its head bright
583 { %GUITAR, slope => 0.6, cutoff => 9000, decay => 2.5, decay_k => 0.2, pluck => 0.08, release => 1,
584 formants => [ [1500, 2, 0.6], [3500, 1.5, 0.6] ] },
585 # 106 Shamisen: thin, its fundamental weak
586 { %GUITAR, slope => 0.8, cutoff => 4000, track => 0, decay => 1.2, pluck => 0.05, release => 0.2,
587 formants => [ [250, -0.95, 0.6], [800, 2, 0.6] ] },
588 # 107 Koto: plucked near the bridge
589 { %GUITAR, slope => 0.7, cutoff => 7000, decay => 2, decay_k => 0.3, pluck => 0.1, release => 1 },
590 # 108 Kalimba: the tine, its click
591 { %MALLET, partials => [ [1, 1, 1], [2, 0.15, 1.2], [5.4, 0.35, 1.3], [8.9, 0.15, 1.5], [13.9, 0.1, 1.8] ], decay => 4,
592 noise => 0.12, noise_center => 3000, noise_decay => 60 },
593 # 109 Bagpipe
594 { %REED, cutoff => 5000, rolloff => 0, attack => 0.1, vibrato => 0, release => 0.05, level => 0.6,
595 formants => [ [1800, 2.5, 0.8] ] },
596 # 110 Fiddle
597 { %STRINGS, cutoff => 3600, vibrato => 18 },
598 # 111 Shanai
599 { %REED, rolloff => 1, formants => [ [250, -0.7, 0.6], [1400, 4, 0.55] ] },
600  
601 # Percussive
602 # 112 Tinkle Bell
603 { %BELL, partials => [ [1, 1, 1], [2.9, 0.5, 2], [5.6, 0.3, 3], [9.1, 0.2, 4] ], decay => 2.5,
604 transpose => 12 },
605 # 113 Agogo: a bell an octave up, struck
606 { %BELL, partials => [ [1, 1, 1], [2.13, 0.3, 1.5], [4.3, 0.6, 2], [6.4, 0.3, 2.5] ], decay => 8, transpose => 12,
607 noise => 0.2, noise_center => 5000, noise_decay => 50 },
608 # 114 Steel Drums: tuned in the octave and the twelfth
609 { %MALLET, partials => [ [1, 0.4, 1], [2, 1, 1.2], [3, 0.8, 1.5], [4, 0.3, 2], [5.4, 0.15, 2.5] ],
610 decay => 3, noise => 0.08, noise_center => 2500, noise_decay => 60 },
611 # 115 Woodblock
612 { %MALLET, partials => [ [1, 1, 1], [2.6, 0.4, 2], [4.7, 0.2, 3] ], decay => 25, noise => 0.3,
613 noise_center => 2500, noise_q => 0.7, noise_decay => 60, transpose => 24 },
614 # 116 Taiko
615 { sweep => 0.4, sweep_time => 0.03, partials => [ [1, 1, 1], [1.6, 0.4, 2] ], decay => 4, attack => 0.002,
616 noise => 0.3, noise_center => 300, noise_mode => 'low', noise_decay => 20 },
617 # 117 Melodic Tom: the head's modes, its strike
618 { sweep => 0.3, sweep_time => 0.06, partials => [ [1, 1, 1], [1.6, 0.4, 2], [2.3, 0.2, 2.5], [2.9, 0.1, 3] ], decay => 5,
619 attack => 0.002, noise => 0.5, noise_center => 1500, noise_q => 0.7, noise_decay => 15 },
620 # 118 Synth Drum
621 { sweep => 1.0, sweep_time => 0.12, partials => [ [1, 1, 1] ], decay => 6, attack => 0.002,
622 noise => 0.35, noise_center => 2500, noise_q => 0.5, noise_decay => 25 },
623 # 119 Reverse Cymbal
624 { partials => [], noise => 0.8, noise_center => 5000, noise_q => 0.7, noise_attack => 1.2, noise_decay => 0,
625 noise_sustain => 1, attack => 1.2, release => 0.05 },
626  
627 # Sound effects
628 # 120 Guitar Fret Noise
629 { partials => [], noise => 1.2, noise_center => 2000, noise_q => 4, noise_decay => 20, attack => 0.01 },
630 # 121 Breath Noise: a breath, let out
631 { partials => [], noise => 0.6, noise_center => 2500, noise_q => 2, noise_attack => 0.1, noise_decay => 3,
632 noise_sustain => 0, release => 0.3 },
633 # 122 Seashore
634 { partials => [], noise => 0.3, noise_center => 2500, noise_mode => 'low', noise_attack => 0.5, noise_decay => 0,
635 noise_sustain => 1, attack => 0.5, release => 2, tremolo => 0.6, trem_rate => 0.15 },
636 # 123 Bird Tweet: chirps, high up
637 { slope => 3, vibrato => 300, vib_rate => 14, vib_delay => 0, attack => 0.01, release => 0.05, decay => 1.5,
638 tremolo => 0.8, trem_rate => 14, transpose => 36, level => 1.5 },
639 # 124 Telephone Ring: a bell, struck and struck
640 { %BELL, partials => [ [1, 1, 0], [2.76, 0.6, 0], [5.4, 0.5, 0], [8.9, 0.4, 0] ], release => 0.1,
641 tremolo => 1, trem_rate => 18, transpose => 24, level => 1.2 },
642 # 125 Helicopter: coming
643 { partials => [], noise => 0.28, noise_center => 1200, noise_mode => 'low', noise_attack => 0.8, noise_decay => 0,
644 noise_sustain => 1, attack => 0.8, tremolo => 0.9, trem_rate => 18, release => 0.5 },
645 # 126 Applause: a crowd's claps at random moments, hands of two colours
646 { partials => [], noise => 0.6, noise_center => 1200, noise_q => 0.8, noise_poles => 4, noise_grains => 300,
647 noise_grain_decay => 90, noise_attack => 0.4, noise_decay => 0, noise_sustain => 1,
648 noise2 => 0.4, noise2_center => 2600, noise2_q => 1.0, noise2_poles => 4, noise2_grains => 200,
649 noise2_grain_decay => 120, noise2_attack => 0.4, noise2_decay => 0, noise2_sustain => 1, release => 1, level => 0.37 },
650 # 127 Gunshot
651 { partials => [], noise => 1, noise_center => 800, noise_mode => 'low', noise_decay => 12, sweep => 0,
652 release => 0.3 },
653 );
654 17 ▶die "the GM table has " . @GM . " programs\n" unless @GM == 128;
Branch: 1 branch
BranchTrueFalseTotal
unless @GM == 128 0 17 17
655  
656 # The variations of the programs, by GS's bank (bank select MSB on a
657 # melodic channel) and program: those FluidR3 has, each a name and its
658 # patch. Each is its program, changed as FluidR3's variation differs from
659 # FluidR3's program (devbin/audit-fluid --variations, against the program
660 # audited): its octave bands, envelope and vibrato, and its level balanced
661 # as the programs' is. Where FluidR3's measures as its program (the
662 # detuned ones), what the name says, mildly: two copies a few cents apart,
663 # beginning in phase.
664 my %VARIATION = (
665 8 => {
666 17 4 => [ 'Detuned EP 1' => { %{ $GM[4] }, unison => 2, detune => 4, unison_sync => 1, level => 0.36 } ],
667 17 5 => [ 'Detuned EP 2' => { %{ $GM[5] }, unison => 2, detune => 4, unison_sync => 1, level => 0.32 } ],
668 17 6 => [ 'Coupled Harpsichord' => { %{ $GM[6] }, even => 1.3, decay => 0.9, unison_sync => 1, level => 0.63 } ],
669 17 14 => [ 'Church Bell' => { %{ $GM[14] }, partials => [ [0.5, 0.35, 0.6], [1, 1, 1], [2.76, 0.5, 1.4],
670 [5.4, 0.3, 2], [8.93, 0.18, 2.5], [13.34, 0.07, 3] ], decay => 1.0, level => 1.41 } ],
671 17 16 => [ 'Detuned Organ 1' => { %{ $GM[16] }, unison => 2, detune => 4, unison_sync => 1, level => 0.21 } ],
672 17 17 => [ 'Detuned Organ 2' => { %{ $GM[17] }, unison => 2, detune => 4, unison_sync => 1, level => 0.52 } ],
673 17 19 => [ 'Church Organ 2' => { %{ $GM[19] }, partials => [ [0.5, 0.25, 0], [1, 1, 0], [2, 0.75, 0], [3, 0.45, 0], [4, 0.55, 0],
674 [5, 0.13, 0], [6, 0.32, 0], [8, 0.38, 0], [10, 0.14, 0], [12, 0.24, 0], [16, 0.2, 0], [20, 0.07, 0], [24, 0.08, 0] ],
675 attack => 0.08, level => 1.07 } ],
676 17 21 => [ 'Italian Accordion' => { %{ $GM[21] }, detune => 44, level => 0.81 } ],
677 17 24 => [ 'Ukulele' => { %{ $GM[24] }, cutoff => 1900, decay => 1.0, release => 0.08, level => 1.04 } ],
678 17 25 => [ '12 String Guitar' => { %{ $GM[25] }, unison => 2, detune => 4, unison_sync => 1, even => 1.5, cutoff => 4500,
679 level => 0.65 } ],
680 17 26 => [ 'Hawaiian Guitar' => { %{ $GM[26] }, cutoff => 1500, vibrato => 6, vib_rate => 5, vib_delay => 0.15,
681 level => 2.01 } ],
682 17 28 => [ 'Funk Guitar' => { %{ $GM[27] }, cutoff => 5000, slope => 0.8, release => 0.03, level => 0.65 } ],
683 17 30 => [ 'Feedback Guitar' => { %{ $GM[30] }, decay => 0, level => 1.1 } ],
684 31 => [ 'Guitar Feedback' => { %LEAD, partials => [ [1, 1, 1], [2, 0.5, 1], [3, 0.35, 1], [4, 0.25, 1], [5, 0.15, 1],
685 [6, 0.1, 1] ], attack => 1.2, release => 0.02, vibrato => 0, level => 0.69 } ],
686 17 38 => [ 'Synth Bass 3' => { %{ $GM[38] }, cutoff => 1300, decay => 0.15, release => 0.05, level => 1.08 } ],
687 17 39 => [ 'Synth Bass 4' => { %{ $GM[39] }, cutoff => 2500, decay => 1.0, release => 0.15, unison => 1, level => 1.13 } ],
688 17 40 => [ 'Slow Violin' => { %{ $GM[40] }, attack => 0.5, level => 0.75 } ],
689 17 48 => [ 'Orchestral Pad' => { %{ $GM[48] }, cutoff => 12000, slope => 0.5, attack => 0.12, fall => 3,
690 17 formants => [ @{ $GM[48]{formants} }, [ 6000, 2, 1 ] ], level => 0.47 } ],
691 17 50 => [ 'Synth Strings 3' => { %{ $GM[50] }, cutoff => 4500, slope => 0.7, attack => 0.35, formants => [ [100, -0.9, 1] ],
692 level => 0.8 } ],
693 17 61 => [ 'Brass 2' => { %{ $GM[61] }, cutoff => 4000, attack => 0.1, vibrato => 24, level => 0.47 } ],
694 17 62 => [ 'Synth Brass 3' => { %{ $GM[62] }, cutoff => 7000, slope => 0.7, attack => 0.005, fall => 1.5, level => 0.68 } ],
695 17 63 => [ 'Synth Brass 4' => { %{ $GM[63] }, detune => 20, unison_sync => 1, level => 0.76 } ],
696 17 80 => [ 'Sine Wave' => { %{ $GM[80] }, partials => [ [1, 1, 1] ], release => 0.02, vibrato => 0, level => 1.78 } ],
697 17 107 => [ 'Taisho Koto' => { %{ $GM[107] }, unison => 2, detune => 3, unison_sync => 1, cutoff => 10000, decay => 1.5,
698 level => 0.56 } ],
699 17 115 => [ 'Castanets' => { %{ $GM[115] }, transpose => 31, decay => 60, noise => 0.5, noise_center => 5000,
700 noise_decay => 120, level => 0.82 } ],
701 17 116 => [ 'Concert Bass Drum' => { %{ $GM[116] }, decay => 3.5, noise_center => 2500, noise_mode => 'band', noise_q => 0.5,
702 level => 1.01 } ],
703 17 117 => [ 'Melo Tom 2' => { %{ $GM[117] }, noise => 0.5, noise_center => 2500, level => 1.17 } ],
704 17 118 => [ '808 Tom' => { %{ $GM[118] }, sweep => 0.3, noise => 0.02, decay => 8, level => 1.75 } ],
705 },
706 9 => {
707 125 => [ 'Burst Noise' => { partials => [], noise => 0.5, noise_center => 3000, noise_mode => 'low', noise_attack => 0.03,
708 noise_decay => 0, noise_sustain => 1, release => 0.5, level => 0.61 } ],
709 },
710 16 => {
711 17 25 => [ 'Mandolin' => { %{ $GM[25] }, unison => 2, detune => 3, unison_sync => 1, cutoff => 3000, decay => 1.2,
712 release => 0.08, level => 0.59 } ],
713 },
714 );
715  
716 # GM2's variations (bank select MSB 121, the LSB the variation) that are
717 # GS's above: by program, LSB => GS bank.
718 my %GM2 = (
719 17 (map { $_ => { 1 => 8 } } 4, 5, 6, 14, 16, 17, 19, 21, 24, 26, 28, 30, 31, 39, 40, 48, 50, 61, 62, 63, 107, 115, 116, 117, 118),
720 25 => { 1 => 8, 2 => 16 },
721 38 => { 2 => 8 },
722 80 => { 2 => 8 },
723 125 => { 9 => 9 },
724 );
725  
726 # The drum kit (GM keys 35 .. 81), measured against FluidR3's standard kit
727 # (devbin/audit-fluid --drums): each drum's pitch, how long it takes to fall
728 # 20 and 40 dB, its spectrum in octaves over the first quarter second, and
729 # its level, balanced as the programs are. A drum sounds at a fixed pitch,
730 # rings to its end whether the key is held or not, and is a sweep, partials
731 # and bands of noise.
732 17 my %KICK = (sweep => 2.2, sweep_time => 0.025,
733 noise => 0.12, noise_mode => 'low', noise_center => 3500, noise_q => 0.7, noise_decay => 50);
734 17 my %SNARE = (fixed => 185, sweep => 0.2, sweep_time => 0.02, partials => [ [1, 0.8, 1], [1.62, 0.5, 1.2], [2.3, 0.2, 1.4] ],
735 noise_mode => 'low', noise_q => 0.7, noise_decay => 22);
736 # A drumhead's modes, for the toms and the hand drums.
737 17 my @MEMBRANE = ([1, 1, 1], [1.59, 0.5, 1.4], [2.14, 0.3, 1.8], [2.65, 0.2, 2.2], [3.16, 0.12, 2.6]);
738 17 my %TOM = (partials => \@MEMBRANE, sweep => 0.35, sweep_time => 0.05,
739 noise => 0.2, noise_mode => 'low', noise_center => 2000, noise_q => 0.7, noise_decay => 30);
740 # Bongos, congas and timbales: hardly a sweep, a little slap high up.
741 17 my %HAND = (%TOM, sweep => 0.05, noise => 0.08, noise_center => 1200,
742 noise2 => 0.015, noise2_center => 8000, noise2_q => 0.6, noise2_decay => 60);
743  
744 # A hi-hat: six metallic partials, its sizzle around 10 kHz, and the stick
745 # (or, the pedal's, the chick) around 600 Hz.
746 51 ▶sub _hat ($decay, $chick, $level) {
Subroutine _hat: called CC=1 SCAR=0.0
747 51 return (fixed => 205.3 * 8, partials => [ map { [ $_ / 205.3, 0.15, 1 ] } 205.3, 304.4, 369.6, 522.7, 540.0, 800.0 ],
748 decay => $decay, noise => 0.9, noise_center => 10000, noise_q => 0.6, noise_decay => $decay,
749 noise2 => $chick, noise2_center => 600, noise2_q => 0.7, noise2_decay => 1.5 * $decay, level => $level);
750 }
751  
752 # A cymbal: nine inharmonic partials, faint; noise in a broad band where it
753 # is loudest, and a second band lower down, the wash.
754 102 ▶sub _cymbal ($fixed, $amplitude, $centre, $decay, $wash, $wash_centre, $level) {
Subroutine _cymbal: called CC=1 SCAR=0.0
755 102 my @ratios = (1, 1.48, 1.93, 2.41, 2.93, 3.39, 4.12, 4.95, 5.71);
756 102 return (fixed => $fixed, partials => [ map { [ $_, $amplitude / sqrt($_), 0.7 + 0.15 * $_ ] } @ratios ],
757 decay => $decay, noise => 0.8, noise_center => $centre, noise_q => 0.7, noise_decay => $decay,
758 noise2 => $wash, noise2_center => $wash_centre, noise2_q => 0.7, noise2_decay => $decay, level => $level);
759 }
760  
761 17 my %DRUM = (
762 35 => { %KICK, fixed => 50, partials => [ [0.7, 0.4, 1], [1, 1, 1], [2.3, 0.1, 3] ], decay => 18, level => 1.34 },
763 36 => { %KICK, fixed => 62, partials => [ [0.6, 0.5, 1], [1, 1, 1], [2.3, 0.1, 3] ], decay => 22, level => 1.24 },
764 # side stick
765 37 => { fixed => 1300, partials => [ [1, 0.35, 1], [1.7, 0.15, 1.5], [1, 0.06, 0.3] ], decay => 25,
766 noise => 1.0, noise_center => 4000, noise_q => 0.5, noise_decay => 60, level => 0.56 },
767 38 => { %SNARE, decay => 30, noise => 0.45, noise_center => 6000, level => 1.58 },
768 # hand clap
769 39 => { partials => [], noise => 1.0, noise_center => 1300, noise_q => 1.2, noise_decay => 28, level => 1.05,
770 tremolo => 0.8, trem_rate => 90 },
771 40 => { %SNARE, fixed => 200, decay => 28, noise => 0.5, noise_center => 5000, level => 1.04 },
772 41 => { %TOM, fixed => 54, decay => 4.2, level => 1.06 },
773 43 => { %TOM, fixed => 72, decay => 6.5, level => 1.31 },
774 45 => { %TOM, fixed => 82, decay => 4.4, level => 0.84 },
775 47 => { %TOM, fixed => 98, decay => 4.8, level => 0.88 },
776 48 => { %TOM, fixed => 106, decay => 5.1, level => 0.91 },
777 50 => { %TOM, fixed => 118, decay => 6.0, level => 0.77 },
778 # closed, pedal and open hi-hat
779 42 => { _hat(23, 0.25, 0.16) },
780 44 => { _hat(33, 0.6, 0.19) },
781 46 => { _hat(2.6, 0.3, 0.12) },
782 # crash 1 and 2, ride 1 and 2, china, splash
783 49 => { _cymbal(420, 0.1, 4500, 1.6, 0.15, 600, 0.28) },
784 57 => { _cymbal(460, 0.1, 5000, 1.8, 0.15, 600, 0.26) },
785 51 => { _cymbal(500, 0.08, 8000, 4, 0.1, 600, 0.28), noise => 0.35 },
786 59 => { _cymbal(560, 0.08, 9000, 4, 0.25, 600, 0.26), noise => 0.35 },
787 52 => { _cymbal(900, 0.1, 4500, 4, 0.4, 1500, 0.25), noise2_q => 1.0 },
788 55 => { _cymbal(900, 0.1, 7000, 4.5, 0.2, 1000, 0.27) },
789 # ride bell
790 53 => { fixed => 3500, partials => [ [0.42, 0.4, 0.8], [0.67, 0.6, 1], [1, 1, 1], [1.5, 0.3, 1.4] ], decay => 2.3,
791 noise => 0.2, noise_center => 6000, noise_q => 0.7, noise_decay => 4,
792 noise2 => 0.2, noise2_center => 800, noise2_q => 0.7, noise2_decay => 4, level => 0.25 },
793 # tambourine
794 54 => { fixed => 6800, partials => [ [1, 0.4, 1], [1.4, 0.3, 1] ], decay => 18, tremolo => 0.5, trem_rate => 40,
795 noise => 0.9, noise_center => 9000, noise_q => 0.6, noise_decay => 18, level => 0.82 },
796 # cowbell
797 56 => { fixed => 480, partials => [ [1, 1, 1], [1.48, 0.15, 1.2], [4.2, 0.3, 1.4], [7.5, 0.1, 1.6] ], decay => 23,
798 noise => 0.08, noise_center => 5000, noise_q => 0.5, level => 0.95 },
799 # vibraslap
800 58 => { fixed => 2400, partials => [ [1, 0.3, 1] ], decay => 3.5, tremolo => 0.9, trem_rate => 28,
801 noise => 0.8, noise_center => 4000, noise_q => 0.5, noise_decay => 3.5, level => 0.5 },
802 # hi and low bongo, mute hi, open hi and low conga, high and low timbale
803 60 => { %HAND, fixed => 870, decay => 38, level => 1.44 },
804 61 => { %HAND, fixed => 590, decay => 29, level => 1.55 },
805 62 => { %HAND, fixed => 860, decay => 50, level => 1.14 },
806 63 => { %HAND, fixed => 290, decay => 15, noise => 0.06, level => 0.95 },
807 64 => { %HAND, fixed => 255, decay => 18, noise => 0.06, level => 1.42 },
808 65 => { %HAND, fixed => 265, decay => 11, noise => 0.3, noise_center => 3000, level => 0.92 },
809 66 => { %HAND, fixed => 200, decay => 10.5, noise => 0.3, noise_center => 3000, level => 1.04 },
810 # high and low agogo
811 67 => { fixed => 1500, partials => [ [1, 1, 1], [2.13, 0.3, 1.4], [4.4, 0.4, 2], [5.9, 0.3, 2.5], [9.5, 0.25, 3] ],
812 decay => 13.5, noise => 0.15, noise_center => 10000, noise_q => 0.6, noise_decay => 20, level => 0.58 },
813 68 => { fixed => 1000, partials => [ [1, 1, 1], [2.13, 0.2, 1.4], [4.3, 0.6, 2], [7.5, 0.4, 2.5], [12, 0.2, 3] ],
814 decay => 12, noise => 0.1, noise_center => 8000, noise_q => 0.6, noise_decay => 20, level => 0.57 },
815 # cabasa, maracas
816 69 => { partials => [], noise => 0.8, noise_center => 12000, noise_q => 0.6, noise_attack => 0.02, noise_decay => 90,
817 level => 1.72 },
818 70 => { partials => [], noise => 0.8, noise_center => 10000, noise_q => 0.7, noise_attack => 0.02, noise_decay => 75,
819 level => 1.16 },
820 # short and long whistle: as long as FluidR3's
821 71 => { fixed => 3150, partials => [ [1, 1, 1], [2, 0.25, 1] ], sweep => -0.1, sweep_time => 0.2, attack => 0.005,
822 decay => 2, length => 0.15, noise => 0.2, noise_center => 8000, noise_q => 0.7, noise_decay => 2, level => 0.76 },
823 72 => { fixed => 2900, partials => [ [1, 1, 1], [2, 0.2, 1] ], sweep => -0.1, sweep_time => 0.4, attack => 0.008,
824 decay => 1, length => 0.35, noise => 0.15, noise_center => 6000, noise_q => 0.7, noise_decay => 1, level => 0.92 },
825 # short and long guiro
826 73 => { partials => [], noise => 0.7, noise_center => 4000, noise_q => 1.2, noise_decay => 30, tremolo => 1,
827 trem_rate => 30, length => 0.12, level => 1.4 },
828 74 => { partials => [], noise => 0.7, noise_center => 4000, noise_q => 1.2, noise_decay => 2, tremolo => 1,
829 trem_rate => 25, length => 0.42, level => 0.86 },
830 # claves
831 75 => { fixed => 2180, partials => [ [1, 1, 1], [2.1, 0.03, 2] ], decay => 90,
832 noise => 0.05, noise_center => 8000, noise_q => 0.7, noise_decay => 150, level => 2.3 },
833 # hi and low wood block: a click, and under it a quieter ring
834 76 => { fixed => 670, partials => [ [1, 1, 1], [1, 0.15, 0.35], [2.7, 0.45, 1.5] ], decay => 80,
835 noise => 0.2, noise_center => 2500, noise_decay => 100, level => 1.83 },
836 77 => { fixed => 560, partials => [ [1, 1, 1], [1, 0.15, 0.35], [2.7, 0.3, 1.5] ], decay => 70,
837 noise => 0.2, noise_center => 2000, noise_decay => 100, level => 1.74 },
838 # mute and open cuica: the pitch rising
839 78 => { fixed => 600, partials => [ [1, 1, 1], [2, 0.3, 1], [3, 0.15, 1.2] ], sweep => -0.15, sweep_time => 0.08,
840 attack => 0.08, decay => 15, level => 4.61 },
841 79 => { fixed => 330, partials => [ [1, 1, 1], [2, 0.3, 1], [3, 0.15, 1.2] ], sweep => -0.15, sweep_time => 0.15,
842 attack => 0.012, decay => 6.2, level => 1.73 },
843 # mute and open triangle
844 80 => { fixed => 7800, partials => [ [0.27, 0.12, 1], [0.5, 0.1, 1], [1, 0.6, 1], [1.44, 1, 1.2], [2, 0.3, 1.4] ],
845 decay => 28, level => 0.76 },
846 81 => { fixed => 7800, partials => [ [0.27, 0.12, 1], [0.5, 0.1, 1], [1, 0.6, 1], [1.44, 1, 1.2], [2, 0.3, 1.4] ],
847 decay => 5.5, level => 0.65 },
848 );
849 17 my $DRUM_FALLBACK = { partials => [], noise => 0.6, noise_center => 3000, noise_q => 0.7, noise_decay => 20, level => 0.4 };
850  
851 # The drum kits a program change on a drum channel picks (GS, GM2 and XG
852 # number them alike): each a name, and the keys that sound otherwise than
853 # the standard kit's, where FluidR3's kit does. Each such drum is the
854 # standard one changed as FluidR3's differs from its standard drum (pitch,
855 # fall, brightness), its level balanced as the kit's (devbin/audit-fluid
856 # --drums --kit N); or, where the kit has another instrument there, that.
857 # The other keys are the standard kit's.
858 #
859 # Room kicks darker, ringing in the room
860 # Power kicks with a hard beater; snares and toms longer, higher
861 # Electronic kicks and toms with a bright attack, the toms diving an
862 # octave from where they are struck
863 # TR-808 sine kicks, toms and congas; thin snares; hi-hats and
864 # cymbal of faint metal and noise; no vibraslap, no timbales
865 # Jazz a low, soft kick; the snare a little darker
866 # Brush the jazz kicks; brushed snare, slap and swirl
867 # Orchestra concert bass drums and snares, timpani F to F (keys 41 to
868 # 53), concert cymbals
869  
870 # The TR-808's hi-hats and cymbal: the hi-hat's metal, faint.
871 17 my @HAT_808 = map { [ $_->[0], 0.03, 1 ] } @{ $DRUM{42}{partials} };
872  
873 # The jazz kit's kicks, the brush kit's too.
874 my %JAZZ_KICKS = (
875 17 35 => { %{ $DRUM{35} }, decay => 16.5, fixed => 40, noise_center => 1700, noise_decay => 65.6, level => 2.3 },
876 17 36 => { %{ $DRUM{36} }, decay => 22, fixed => 33.6, noise_center => 1290, noise_decay => 55.6, level => 2.51 },
877 );
878  
879 my %KIT = (
880 0 => [ Standard => {} ],
881 8 => [ Room => {
882 17 35 => { %{ $DRUM{35} }, decay => 24, noise_center => 1490, noise_decay => 68.5, level => 2.37 },
883 17 36 => { %{ $DRUM{36} }, decay => 20.5, fixed => 58.5, noise_center => 1530, noise_decay => 58.1,
884 level => 2.01 },
885 } ],
886 16 => [ Power => {
887 17 35 => { %{ $DRUM{35} }, decay => 11.7, noise_center => 6000, noise_decay => 32.5, level => 1.76 },
888 17 36 => { %{ $DRUM{36} }, decay => 9.4, noise_center => 10000, noise_decay => 21.4, level => 1.67 },
889 17 38 => { %{ $DRUM{38} }, decay => 13.4, fixed => 292, noise_center => 7790, noise_decay => 9.8, level => 1.18 },
890 17 40 => { %{ $DRUM{40} }, decay => 15.9, fixed => 221, noise_decay => 12.5, level => 1.15 },
891 17 41 => { %{ $DRUM{41} }, decay => 7.08, fixed => 70.2, noise => 0.35, noise_center => 1630,
892 noise_decay => 50.6, level => 1.22 },
893 17 43 => { %{ $DRUM{43} }, decay => 5.18, noise => 0.35, noise_center => 2580, noise_decay => 23.9,
894 level => 1.18 },
895 17 45 => { %{ $DRUM{45} }, decay => 6.25, fixed => 98.9, noise => 0.35, noise_center => 2560,
896 noise_decay => 42.6, level => 1.42 },
897 17 47 => { %{ $DRUM{47} }, decay => 6.76, fixed => 116, noise => 0.35, noise_center => 2900,
898 noise_decay => 42.3, level => 1.38 },
899 17 48 => { %{ $DRUM{48} }, decay => 7.98, fixed => 131, noise => 0.35, noise_center => 2970, noise_decay => 47,
900 level => 1.27 },
901 17 50 => { %{ $DRUM{50} }, decay => 9.07, fixed => 157, noise => 0.35, noise_center => 3650,
902 noise_decay => 45.4, level => 1.34 },
903 } ],
904 24 => [ Electronic => {
905 17 35 => { %{ $DRUM{35} }, decay => 12.2, noise => 0.25, noise_center => 3500, noise_decay => 33.9,
906 noise_mode => 'band', noise_q => 0.5, level => 1.8 },
907 17 36 => { %{ $DRUM{36} }, decay => 16.9, noise => 0.25, noise_center => 3500, noise_decay => 38.5,
908 noise_mode => 'band', noise_q => 0.5, level => 1.72 },
909 17 38 => { %{ $DRUM{38} }, decay => 12.8, fixed => 119, noise_center => 5000, noise_decay => 9.4, level => 1.14 },
910 17 40 => { %{ $DRUM{40} }, decay => 15, fixed => 162, noise_decay => 11.8, level => 1.11 },
911 17 41 => { %{ $DRUM{41} }, attack => 0.01, decay => 4.74, fixed => 82.3, noise => 0.4, noise_center => 4000,
912 noise_decay => 33.8, noise_mode => 'band', noise_q => 0.5, sweep => 1, sweep_time => 0.15, level => 1.3 },
913 17 43 => { %{ $DRUM{43} }, attack => 0.01, decay => 5.02, fixed => 92.5, noise => 0.4, noise_center => 4000,
914 noise_decay => 23.2, noise_mode => 'band', noise_q => 0.5, sweep => 1, sweep_time => 0.15, level => 1.41 },
915 17 45 => { %{ $DRUM{45} }, attack => 0.01, decay => 5.72, fixed => 102, noise => 0.4, noise_center => 4000,
916 noise_decay => 39, noise_mode => 'band', noise_q => 0.5, sweep => 1, sweep_time => 0.15, level => 1.43 },
917 17 47 => { %{ $DRUM{47} }, attack => 0.01, decay => 6.46, fixed => 113, noise => 0.4, noise_center => 4000,
918 noise_decay => 40.4, noise_mode => 'band', noise_q => 0.5, sweep => 1, sweep_time => 0.15, level => 1.46 },
919 17 48 => { %{ $DRUM{48} }, attack => 0.01, decay => 8.51, fixed => 142, noise => 0.4, noise_center => 4000,
920 noise_decay => 50.1, noise_mode => 'band', noise_q => 0.5, sweep => 1, sweep_time => 0.15, level => 1.35 },
921 17 50 => { %{ $DRUM{50} }, attack => 0.01, decay => 11.3, fixed => 167, noise => 0.4, noise_center => 4000,
922 noise_decay => 56.5, noise_mode => 'band', noise_q => 0.5, sweep => 1, sweep_time => 0.15, level => 1.26 },
923 } ],
924 25 => [ 'TR-808' => {
925 17 35 => { %{ $DRUM{35} }, decay => 27.7, noise => 0.01, noise_center => 875, noise_decay => 76.8,
926 partials => [ [ 1, 1, 1 ] ], sweep => 0.6, sweep_time => 0.03, level => 4.22 },
927 17 36 => { %{ $DRUM{36} }, fixed => 41.3, noise => 0.01, noise_center => 875, partials => [ [ 1, 1, 1 ] ],
928 sweep => 0.6, sweep_time => 0.03, level => 3.95 },
929 17 38 => { %{ $DRUM{38} }, fixed => 155, noise_center => 4500, noise_mode => 'band', level => 2.14 },
930 17 39 => { %{ $DRUM{39} }, noise2 => 0.15, noise2_center => 1300, noise2_decay => 8, noise2_q => 1.2,
931 noise_center => 900, noise_decay => 23.7, level => 1.73 },
932 17 40 => { %{ $DRUM{40} }, decay => 47.7, fixed => 155, noise_center => 4000, noise_decay => 37.5,
933 noise_mode => 'band', level => 2.02 },
934 17 41 => { %{ $DRUM{41} }, decay => 11.5, fixed => 85.5, noise => 0.015, noise_center => 500,
935 noise_decay => 81.9, partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ], sweep => 0.25, level => 3.62 },
936 17 42 => { %{ $DRUM{42} }, decay => 47.8, fixed => 2480, noise2 => 0, noise_center => 8000, noise_decay => 47.8,
937 partials => \@HAT_808, level => 1.55 },
938 17 43 => { %{ $DRUM{43} }, decay => 14.4, fixed => 102, noise => 0.015, noise_center => 500,
939 noise_decay => 66.5, partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ], sweep => 0.25, level => 3.45 },
940 17 44 => { %{ $DRUM{44} }, decay => 13, noise2 => 0, noise_center => 8000, noise_decay => 13,
941 partials => \@HAT_808, level => 1.36 },
942 17 45 => { %{ $DRUM{45} }, decay => 18.8, fixed => 128, noise => 0.015, noise_center => 500, noise_decay => 128,
943 partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ], sweep => 0.25, level => 3.73 },
944 17 46 => { %{ $DRUM{46} }, decay => 6.88, noise2 => 0, noise_center => 8000, noise_decay => 6.88,
945 partials => \@HAT_808, level => 1.31 },
946 17 47 => { %{ $DRUM{47} }, decay => 12.3, fixed => 155, noise => 0.015, noise_center => 500,
947 noise_decay => 76.9, partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ], sweep => 0.25, level => 3.68 },
948 17 48 => { %{ $DRUM{48} }, decay => 13.5, fixed => 191, noise => 0.015, noise_center => 500,
949 noise_decay => 79.2, partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ], sweep => 0.25, level => 3.63 },
950 17 50 => { %{ $DRUM{50} }, decay => 23.5, fixed => 232, noise => 0.015, noise_center => 520, noise_decay => 118,
951 partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ], sweep => 0.25, level => 3.86 },
952 17 51 => { %{ $DRUM{46} }, decay => 7.73, noise2 => 0, noise_center => 8000, noise_decay => 7.73,
953 partials => \@HAT_808, level => 1.4 },
954 17 56 => { %{ $DRUM{56} }, decay => 18.3, fixed => 540, noise => 0.02, noise_center => 2720,
955 noise_decay => 23.9, partials => [ [ 1, 0.7, 1 ], [ 1.48, 1, 1 ] ], level => 2.79 },
956 58 => { partials => [], level => 0 },
957 17 62 => { %{ $DRUM{62} }, decay => 26.9, fixed => 404, noise => 0, noise2 => 0,
958 partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ], sweep => 0.05, level => 2.85 },
959 17 63 => { %{ $DRUM{63} }, decay => 24.8, fixed => 263, noise => 0, noise2 => 0,
960 partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ], sweep => 0.05, level => 2.88 },
961 17 64 => { %{ $DRUM{64} }, fixed => 186, noise => 0, noise2 => 0, partials => [ [ 1, 1, 1 ], [ 2, 0.05, 2 ] ],
962 sweep => 0.05, level => 2.97 },
963 65 => { partials => [], level => 0 },
964 66 => { partials => [], level => 0 },
965 17 75 => { %{ $DRUM{75} }, noise => 0.01, noise_center => 6550, level => 4.92 },
966 } ],
967 32 => [ Jazz => {
968 %JAZZ_KICKS,
969 17 38 => { %{ $DRUM{38} }, fixed => 199, noise_center => 4800, level => 1.16 },
970 } ],
971 40 => [ Brush => {
972 %JAZZ_KICKS,
973 17 38 => { %{ $DRUM{38} }, decay => 37.3, fixed => 276, noise_decay => 27.3, level => 0.679 },
974 17 39 => { %{ $DRUM{39} }, decay => 30, fixed => 165, noise_center => 929, noise_decay => 32.1,
975 partials => [ [ 1, 0.3, 1 ] ], level => 0.707 },
976 17 40 => { %{ $DRUM{40} }, decay => 10.7, fixed => 127, noise_attack => 0.05, noise_decay => 8.43,
977 level => 0.291 },
978 } ],
979 48 => [ Orchestra => {
980 17 35 => { %{ $DRUM{35} }, decay => 4.31, fixed => 133, noise => 0.08, noise_center => 2000, noise_decay => 12,
981 sweep => 0.3, level => 1.01 },
982 17 36 => { %{ $DRUM{36} }, decay => 4.53, fixed => 141, noise => 0.08, noise_center => 2000,
983 noise_decay => 10.3, sweep => 0.3, level => 1.09 },
984 17 38 => { %{ $DRUM{38} }, decay => 18.6, fixed => 214, noise_center => 7740, noise_decay => 13.7,
985 level => 0.723 },
986 17 40 => { %{ $DRUM{40} }, decay => 19.2, fixed => 214, noise_center => 6610, noise_decay => 15.1,
987 level => 0.701 },
988 17 41 => { %{ $GM[47] }, decay => 4, fixed => 87.3, level => 0.731 },
989 17 42 => { %{ $GM[47] }, decay => 4, fixed => 92.5, level => 0.718 },
990 17 43 => { %{ $GM[47] }, decay => 4, fixed => 98, level => 0.536 },
991 17 44 => { %{ $GM[47] }, decay => 4, fixed => 104, level => 0.558 },
992 17 45 => { %{ $GM[47] }, decay => 4, fixed => 110, level => 0.547 },
993 17 46 => { %{ $GM[47] }, decay => 4, fixed => 117, level => 0.525 },
994 17 47 => { %{ $GM[47] }, decay => 4, fixed => 123, level => 0.534 },
995 17 48 => { %{ $GM[47] }, decay => 4, fixed => 131, level => 0.533 },
996 17 49 => { %{ $GM[47] }, decay => 4, fixed => 139, level => 0.497 },
997 17 50 => { %{ $GM[47] }, decay => 4, fixed => 147, level => 0.525 },
998 17 51 => { %{ $GM[47] }, decay => 4, fixed => 156, level => 0.516 },
999 17 52 => { %{ $GM[47] }, decay => 4, fixed => 165, level => 0.519 },
1000 17 53 => { %{ $GM[47] }, decay => 4, fixed => 175, level => 0.537 },
1001 17 57 => { %{ $DRUM{57} }, decay => 2.45, fixed => 594, noise2_decay => 2.45, noise_center => 7360,
1002 noise_decay => 2.45, level => 0.393 },
1003 17 59 => { %{ $DRUM{59} }, decay => 5, noise_center => 12000, level => 0.596 },
1004 } ],
1005 );
1006  
1007 17 my (%PROGRAM_PATCH, %DRUM_PATCH);
1008  
1009 # The patch of a program, or of a variation of it (by its GS bank).
1010 760 ▶sub program ($number, $bank = 0) {
Subroutine program: called CC=7 SCAR=20.3
Pod documented
1011 760 ▶ return $PROGRAM_PATCH{"$bank:$number"} //= do {
Condition66%2/3
$PROGRAM_PATCH{"${bank}:$number"} //= do { my $variation = $bank && ($VARIATION{$bank}{$number} // die("no variation $bank of program $number\n")); _make(%{$variation ? $$variation[1] : $GM[$number] // die("no GM program $number\n");}) }
l!l&&r!l&&!r
4423180
MC/DC0%0/2
$PROGRAM_PATCH{"${bank}:$number"} //= do { my $variation = $bank && ($VARIATION{$bank}{$number} // die("no variation $bank of program $number\n")); _make(%{$variation ? $$variation[1] : $GM[$number] // die("no GM program $number\n");}) }
$PROGRAM_PATCH{"${bank}:$number"} do { my $variation = $bank && ($VARIATION{$bank}{$number} // die("no variation $bank of program $number\n")); _make(%{$variation ? $$variation[1] : $GM[$number] // die("no GM program $number\n");}) }
Truth table66%2/3
A //= B
A= $PROGRAM_PATCH{"${bank}:$number"}B= do { my $variation = $bank && ($VARIATION{$bank}{$number} // die("no variation $bank of program $number\n")); _make(%{$variation ? $$variation[1] : $GM[$number] // die("no GM program $number\n");}) }
ABresult
1X1
011
000
1012 318 ▶ my $variation = $bank && ($VARIATION{$bank}{$number} // die "no variation $bank of program $number\n");
Condition60%3/5
$bank && ($VARIATION{$bank}{$number} // die("no variation $bank of program $number\n"))
!ll&&!rl&&r
286032
$VARIATION{$bank}{$number} // die("no variation $bank of program $number\n")
l!l
320
MC/DC50%1/2
$bank && ($VARIATION{$bank}{$number} // die("no variation $bank of program $number\n"))
$bank $VARIATION{$bank}{$number}
Truth table66%2/3
A && B
A= $bankB= $VARIATION{$bank}{$number}
ABresult
0X0
100
111
1013 318 ▶ _make(%{ $variation ? $variation->[1] : $GM[$number] // die "no GM program $number\n" });
Branch: 1 branch
BranchTrueFalseTotal
$variation ? : 32 286 318
Condition50%1/2
$GM[$number] // die("no GM program $number\n")
l!l
2860
MC/DC0%0/1
$GM[$number] // die("no GM program $number\n")
$GM[$number]
Truth table50%1/2
A
A= $GM[$number]
Aresult
11
00
1014 };
1015 }
1016  
1017 # The patch of a drum key in a kit: the kit's own, or the standard kit's.
1018 680 ▶sub drum ($key, $kit = 0) {
Subroutine drum: called CC=5 SCAR=16.3
Pod documented
1019 680 $kit = kit_key($kit, $key);
1020 return $DRUM_PATCH{"$kit:$key"} //= _make(
1021 attack => 0.0005, release => 0.05, sustain => 1, velocity => 1.4, length => 4,
1022 680 ▶ %{ $kit ? $KIT{$kit}[1]{$key} : $DRUM{$key} // $DRUM_FALLBACK }, drum => 1,
Branch: 1 branch
BranchTrueFalseTotal
$kit ? : 75 124 199
Condition66%4/6
$DRUM_PATCH{"${kit}:$key"} //= _make("attack", "0.0005", "release", "0.05", "sustain", 1, "velocity", "1.4", "length", 4, %{$kit ? $KIT{$kit}[1]{$key} : $DRUM{$key} // $DRUM_FALLBACK;}, "drum", 1)
l!l&&r!l&&!r
4811990
$DRUM{$key} // $DRUM_FALLBACK
l!l&&r!l&&!r
108160
MC/DC0%0/2
$DRUM_PATCH{"${kit}:$key"} //= _make("attack", "0.0005", "release", "0.05", "sustain", 1, "velocity", "1.4", "length", 4, %{$kit ? $KIT{$kit}[1]{$key} : $DRUM{$key} // $DRUM_FALLBACK;}, "drum", 1)
$DRUM_PATCH{"${kit}:$key"} _make("attack", "0.0005", "release", "0.05", "sustain", 1, "velocity", "1.4", "length", 4, %{$kit ? $KIT{$kit}[1]{$key} : $DRUM{$key} // $DRUM_FALLBACK;}, "drum", 1)
MC/DC0%0/2
$DRUM{$key} // $DRUM_FALLBACK
$DRUM{$key} $DRUM_FALLBACK
Truth table66%2/3
A //= B
A= $DRUM_PATCH{"${kit}:$key"}B= _make("attack", "0.0005", "release", "0.05", "sustain", 1, "velocity", "1.4", "length", 4, %{$kit ? $KIT{$kit}[1]{$key} : $DRUM{$key} // $DRUM_FALLBACK;}, "drum", 1)
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $DRUM{$key}B= $DRUM_FALLBACK
ABresult
1X1
011
000
1023 );
1024 }
1025  
1026 # The GS bank of the variation a bank select picks for a program: GS's own
1027 # (the MSB) where there is that variation, GM2's (MSB 121, the LSB the
1028 # variation) where it is one of these; else 0, the program itself, as GS
1029 # and XG play what they do not have (XG's variations are not here).
1030 344 ▶sub variation ($msb, $lsb, $program) {
Subroutine variation: called CC=5 SCAR=16.1
Pod documented
1031 344 ▶ return $GM2{$program}{$lsb} // 0 if $msb == 121;
Branch: 1 branch
BranchTrueFalseTotal
if $msb == 121 3 341 344
Condition50%1/2
$GM2{$program}{$lsb} // 0
l!l
30
MC/DC0%0/1
$GM2{$program}{$lsb} // 0
$GM2{$program}{$lsb}
Truth table50%1/2
A
A= $GM2{$program}{$lsb}
Aresult
11
00
1032 341 ▶ return $VARIATION{$msb} && $VARIATION{$msb}{$program} ? $msb : 0;
Branch: 1 branch
BranchTrueFalseTotal
$VARIATION{$msb} && $VARIATION{$msb}{$program} ? : 8 333 341
Condition100%3/3
$VARIATION{$msb} and $VARIATION{$msb}{$program}
!ll&&!rl&&r
33038
MC/DC100%2/2
$VARIATION{$msb} and $VARIATION{$msb}{$program}
$VARIATION{$msb} $VARIATION{$msb}{$program}
Truth table100%3/3
A and B
A= $VARIATION{$msb}B= $VARIATION{$msb}{$program}
ABresult
0X0
100
111
1033 }
1034  
1035 # The kit a program change on a drum channel picks: its own, or the kit
1036 # its group of eight begins with (GS's Room 2 and Jazz 3 are Room and Jazz
1037 # here), or the standard kit.
1038 328 ▶sub kit ($program) {
Subroutine kit: called CC=3 SCAR=11.0
Pod documented
1039 328 ▶ return $program if $KIT{$program};
Branch: 1 branch
BranchTrueFalseTotal
if $KIT{$program} 54 274 328
1040 274 my $group = $program - $program % 8;
1041 274 ▶ return $KIT{$group} ? $group : 0;
Branch: 1 branch
BranchTrueFalseTotal
$KIT{$group} ? : 114 160 274
1042 }
1043  
1044 # The kit whose patch a key of a kit plays: the kit, where it has the key
1045 # as its own, or the standard kit.
1046 831 ▶sub kit_key ($kit, $key) {
Subroutine kit_key: called CC=3 SCAR=11.1
Pod documented
1047 831 ▶ return $KIT{$kit} && $KIT{$kit}[1]{$key} ? $kit : 0;
Branch: 1 branch
BranchTrueFalseTotal
$KIT{$kit} && $KIT{$kit}[1]{$key} ? : 76 755 831
Condition66%2/3
$KIT{$kit} and $KIT{$kit}[1]{$key}
!ll&&!rl&&r
075576
MC/DC50%1/2
$KIT{$kit} and $KIT{$kit}[1]{$key}
$KIT{$kit} $KIT{$kit}[1]{$key}
Truth table66%2/3
A and B
A= $KIT{$kit}B= $KIT{$kit}[1]{$key}
ABresult
0X0
100
111
1048 }
1049  
1050 63 ▶sub fields () { return sort keys %DEFAULT }
Subroutine fields: called CC=1 SCAR=0.0
Pod documented
1051  
1052 # Every field's default, as a patch made of nothing has it (a copy).
1053 4 ▶sub defaults () { return { map { $_ => ref $DEFAULT{$_} ? [ @{ $DEFAULT{$_} } ] : $DEFAULT{$_} } keys %DEFAULT } }
Subroutine defaults: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref $DEFAULT{$_} ? : 8 552 560
1054  
1055 # What an editor needs to know of the fields: the group they belong to, their
1056 # range, whether the range is better walked in steps of equal ratio (log),
1057 # and what they do. Fields not listed (partials, formants, drum) are edited
1058 # otherwise or not at all.
1059 my @FIELD_INFO = (
1060 [ spectrum => slope => 0, 10, 'lin', 'how fast the harmonics fall: amplitude k^-slope' ],
1061 [ spectrum => even => 0, 2, 'lin', 'level of the even harmonics (low: hollow, clarinet-like; high: an octave reed or pipe)' ],
1062 [ spectrum => cutoff => 100, 16000, 'log', 'soft low-pass on the harmonics (Hz)' ],
1063 [ spectrum => rolloff => 0, 3, 'int', 'the low-pass steeper: 12 dB an octave more for each' ],
1064 [ spectrum => track => 0, 1, 'lin', 'how much the cutoff follows the key' ],
1065 [ spectrum => bright => 0, 3, 'lin', 'how much velocity opens the cutoff' ],
1066 [ spectrum => pluck => 0, 0.5, 'lin', 'pluck or strike position: harmonics with a node there are weak' ],
1067 [ spectrum => stretch => 0, 0.002, 'lin', 'inharmonicity: upper partials stretched sharp (piano strings)' ],
1068 [ spectrum => stretch_key => 0, 3, 'lin', 'the stiffness grows with the key: B doubles every 12 / stretch_key semitones up' ],
1069 [ spectrum => max => 1, 256, 'log', 'harmonics at most' ],
1070 [ partials => decay => 0, 100, 'log', 'decay of the fundamental (1/s); 0 sustains' ],
1071 [ partials => decay_k => 0, 2, 'lin', 'upper partials decay this much faster, per partial' ],
1072 [ partials => decay_key => 0, 2, 'lin', 'higher keys decay faster' ],
1073 [ partials => decay_k_key => 0, 3, 'lin', 'decay_k grows with the key: the upper partials die sooner in the treble' ],
1074 [ partials => attack_k => 0, 0.05, 'lin', 'upper partials come in later (s per partial)' ],
1075 [ envelope => attack => 0.0005, 4, 'log', 'attack time (s)' ],
1076 [ envelope => hold => 0, 2, 'lin', 'time at full level (s)' ],
1077 [ envelope => fall => 0.01, 10, 'log', 'decay time constant towards sustain (s)' ],
1078 [ envelope => sustain => 0, 1, 'lin', 'sustain level' ],
1079 [ envelope => release => 0.005, 5, 'log', 'release time constant (s)' ],
1080 [ envelope => level => 0, 5, 'lin', 'level' ],
1081 [ envelope => velocity => 0, 3, 'lin', 'velocity sensitivity: loudness (velocity/127)^this' ],
1082 [ pitch => transpose => -48, 48, 'int', 'semitones' ],
1083 [ pitch => fixed => 0, 8000, 'lin', 'a fixed pitch in Hz, whatever the key (0: off)' ],
1084 [ pitch => sweep => -1, 4, 'lin', 'the pitch starts this much higher (ratio - 1) ...' ],
1085 [ pitch => sweep_time => 0.001, 1, 'log', '... and falls back with this time constant (s)' ],
1086 [ pitch => vibrato => 0, 400, 'log', 'vibrato depth (cents)' ],
1087 [ pitch => vib_rate => 0.1, 20, 'log', 'vibrato rate (Hz)' ],
1088 [ pitch => vib_delay => 0, 2, 'lin', 'vibrato fades in after (s)' ],
1089 [ pitch => tremolo => 0, 1, 'lin', 'tremolo depth' ],
1090 [ pitch => trem_rate => 0.1, 100, 'log', 'tremolo rate (Hz)' ],
1091 [ unison => unison => 1, 5, 'int', 'detuned copies of the partials' ],
1092 [ unison => detune => 0, 50, 'lin', 'cents between the outermost copies' ],
1093 [ unison => unison_k => 1, 64, 'int', 'partials each copy carries' ],
1094 [ unison => unison_sync => 0, 1, 'int', '1: the copies begin in phase, as strings struck by one hammer (0: each its own)' ],
1095 [ noise => noise => 0, 2, 'lin', 'noise level' ],
1096 [ noise => noise_center => 20, 20000, 'log', 'noise band centre (Hz)' ],
1097 [ noise => noise_ratio => 0, 16, 'lin', 'noise band centre as a multiple of the pitch (0: use Hz)' ],
1098 [ noise => noise_q => 0.1, 10, 'log', 'noise band narrowness (Q)' ],
1099 [ noise => noise_attack => 0.0005, 4, 'log', 'noise attack (s)' ],
1100 [ noise => noise_decay => 0, 200, 'lin', 'noise decay (1/s)' ],
1101 [ noise => noise_sustain => 0, 1, 'lin', 'noise level left after the decay' ],
1102 [ noise => noise_mode => 'band', 'low', 'choice', 'band-, high- or low-pass', [qw(band high low)] ],
1103 [ noise => noise_poles => 2, 4, 'choice', 'the filter: 2 poles, or 4 for twice as steep', [ 2, 4 ] ],
1104 [ noise => noise_grains => 0, 2000, 'log', 'bursts a second at random moments (applause, rain); 0: steady' ],
1105 [ noise => noise_grain_decay => 10, 1000, 'log', 'how fast a burst falls (1/s)' ],
1106 (map {
1107 34 my ($b, $n) = @$_;
1108 34 [ $b => $b => 0, 2, 'lin', "band $n: level" ],
1109 [ $b => "${b}_center" => 20, 20000, 'log', "band $n: centre (Hz)" ],
1110 [ $b => "${b}_ratio" => 0, 16, 'lin', "band $n: centre as a multiple of the pitch (0: use Hz)" ],
1111 [ $b => "${b}_q" => 0.1, 10, 'log', "band $n: narrowness (Q)" ],
1112 [ $b => "${b}_attack" => 0.0005, 4, 'log', "band $n: attack (s)" ],
1113 [ $b => "${b}_decay" => 0, 200, 'lin', "band $n: decay (1/s)" ],
1114 [ $b => "${b}_sustain" => 0, 1, 'lin', "band $n: level left after the decay" ],
1115 [ $b => "${b}_mode" => 'band', 'low', 'choice', "band $n: band-, high- or low-pass", [qw(band high low)] ],
1116 [ $b => "${b}_poles" => 2, 4, 'choice', "band $n: the filter's poles", [ 2, 4 ] ],
1117 [ $b => "${b}_grains" => 0, 2000, 'log', "band $n: bursts a second; 0: steady" ],
1118 [ $b => "${b}_grain_decay" => 10, 1000, 'log', "band $n: how fast a burst falls (1/s)" ],
1119 } [ noise2 => 2 ], [ noise3 => 3 ]),
1120 [ string => string => 0, 2, 'lin', 'a string (Karplus-Strong), plucked or struck: its level' ],
1121 [ string => string_decay => 0.05, 30, 'log', 'seconds it falls 60 dB in, at middle C' ],
1122 [ string => string_key => 0, 2, 'lin', 'higher keys decay faster' ],
1123 [ string => string_damp => 0, 0.95, 'lin', 'damping in the loop: the highs die sooner' ],
1124 [ string => string_pick => 0, 0.5, 'lin', 'where along the string it is plucked or struck' ],
1125 [ string => string_bright => 0.01, 1, 'log', 'how bright the pluck is (struck: how hard the hammer is)' ],
1126 [ string => string_vel => 0, 3, 'lin', 'how much velocity brightens the pluck' ],
1127 [ string => string_noise => 0, 1, 'lin', 'how much of the pluck is noise (the rest the plucked string\'s shape)' ],
1128 [ string => string_excite => 'pluck', 'strike', 'choice', 'plucked, or struck by a hammer (string_bright: how hard it is)' ],
1129 [ string => string_stiff => 0, 0.002, 'lin', 'stiffness: upper harmonics sharp, as stretch has the partials (piano strings)' ],
1130 [ fm => fm => 0, 2, 'lin', 'FM (four operators): its level' ],
1131 [ fm => fm_alg => 1, 8, 'int', 'the algorithm: 1 4>3>2>1; 2 (4+3)>2>1; 3 (4+(3>2))>1; 4 ((4>3)+2)>1; 5 4>3, 2>1; 6 4>3,2,1; 7 4>3, 2, 1; 8 all four' ],
1132 [ fm => fm_fb => 0, 1, 'lin', 'operator 4 modulating itself (feedback)' ],
1133 (map {
1134 17 my $o = $_;
1135 68 my $g = "op$o";
1136 68 [ $g => "${g}_ratio" => 0.25, 32, 'log', "operator $o: frequency, times the note's" ],
1137 [ $g => "${g}_detune" => -50, 50, 'lin', "operator $o: detune (cents)" ],
1138 [ $g => "${g}_level" => 0, 10, 'lin', "operator $o: amplitude as a carrier, index (radians) as a modulator" ],
1139 [ $g => "${g}_attack" => 0.0005, 4, 'log', "operator $o: attack (s)" ],
1140 [ $g => "${g}_decay" => 0.005, 20, 'log', "operator $o: decay time constant (s)" ],
1141 [ $g => "${g}_sustain" => 0, 1, 'lin', "operator $o: sustain level" ],
1142 [ $g => "${g}_release" => 0.005, 10, 'log', "operator $o: release time constant (s)" ],
1143 [ $g => "${g}_vel" => 0, 1, 'lin', "operator $o: how much velocity moves its level" ],
1144 [ $g => "${g}_key" => -2, 2, 'lin', "operator $o: higher keys, lower level (this power of the pitch)" ],
1145 } 1 .. 4),
1146 [ noise => rough => 0, 1, 'lin', 'noise on the partials: how much it moves their amplitude' ],
1147 [ noise => rough_rate => 5, 5000, 'log', 'noise on the partials: how fast it moves (Hz)' ],
1148 [ filter => filter => 'off', 'bp', 'choice', 'the filter: low-pass of 12 or 24 dB an octave, high-pass, band-pass', [qw(off lp12 lp24 hp12 hp24 bp)] ],
1149 [ filter => filter_cutoff => 20, 20000, 'log', 'cutoff at middle C (Hz)' ],
1150 [ filter => filter_track => 0, 1, 'lin', 'how much the cutoff follows the key' ],
1151 [ filter => filter_q => 0.5, 20, 'log', 'resonance (Q)' ],
1152 [ filter => filter_env => -8, 8, 'lin', 'octaves the second envelope moves the cutoff' ],
1153 [ filter => filter_vel => -4, 4, 'lin', 'octaves velocity moves the cutoff' ],
1154 [ env2 => env2_attack => 0.0005, 4, 'log', 'attack (s)' ],
1155 [ env2 => env2_decay => 0.005, 10, 'log', 'decay time constant (s)' ],
1156 [ env2 => env2_sustain => 0, 1, 'lin', 'sustain level' ],
1157 [ env2 => env2_release => 0.005, 10, 'log', 'release time constant (s)' ],
1158 [ lfo => lfo1_rate => 0.01, 50, 'log', 'first LFO: rate (Hz)' ],
1159 [ lfo => lfo1_shape => 'sine', 'random', 'choice', 'first LFO: shape', [qw(sine triangle square saw random)] ],
1160 [ lfo => lfo1_delay => 0, 5, 'lin', 'first LFO: fades in over (s)' ],
1161 [ lfo => lfo2_rate => 0.01, 50, 'log', 'second LFO: rate (Hz)' ],
1162 [ lfo => lfo2_shape => 'sine', 'random', 'choice', 'second LFO: shape', [qw(sine triangle square saw random)] ],
1163 [ lfo => lfo2_delay => 0, 5, 'lin', 'second LFO: fades in over (s)' ],
1164 [ pitch => length => 0, 10, 'lin', 'a drum rings this long at most (s)' ],
1165 );
1166  
1167 # The fields as an editor shows them: name, group, min, max, scale, what it
1168 # does; a choice's options (its first and last are min and max).
1169 15 ▶sub field_info () {
Subroutine field_info: called CC=4 SCAR=13.9
Pod documented
1170 15 my @info;
1171 15 for my $field (@FIELD_INFO) {
1172 2040 my ($group, $name, $min, $max, $scale, $about, $choices) = @$field;
1173 2040 ▶ push @info, {
Branch: 1 branch
BranchTrueFalseTotal
$scale eq 'choice' ? : 150 1890 2040
Condition100%2/2
$choices // [$min, $max]
l!l
13515
MC/DC100%1/1
$choices // [$min, $max]
$choices
Truth table100%2/2
A
A= $choices
Aresult
11
00
1174 group => $group,
1175 name => $name,
1176 min => $min,
1177 max => $max,
1178 scale => $scale,
1179 about => $about,
1180 $scale eq 'choice' ? (choices => $choices // [ $min, $max ]) : (),
1181 };
1182 }
1183 15 return \@info;
1184 }
1185  
1186 17 my @PROGRAM_NAMES = (
1187 'Acoustic Grand Piano', 'Bright Acoustic Piano', 'Electric Grand Piano', 'Honky-tonk Piano', 'Electric Piano 1',
1188 'Electric Piano 2', 'Harpsichord', 'Clavinet', 'Celesta', 'Glockenspiel', 'Music Box', 'Vibraphone', 'Marimba',
1189 'Xylophone', 'Tubular Bells', 'Dulcimer', 'Drawbar Organ', 'Percussive Organ', 'Rock Organ', 'Church Organ',
1190 'Reed Organ', 'Accordion', 'Harmonica', 'Tango Accordion', 'Acoustic Guitar (nylon)', 'Acoustic Guitar (steel)',
1191 'Electric Guitar (jazz)', 'Electric Guitar (clean)', 'Electric Guitar (muted)', 'Overdriven Guitar',
1192 'Distortion Guitar', 'Guitar Harmonics', 'Acoustic Bass', 'Electric Bass (finger)', 'Electric Bass (pick)',
1193 'Fretless Bass', 'Slap Bass 1', 'Slap Bass 2', 'Synth Bass 1', 'Synth Bass 2', 'Violin', 'Viola', 'Cello',
1194 'Contrabass', 'Tremolo Strings', 'Pizzicato Strings', 'Orchestral Harp', 'Timpani', 'String Ensemble 1',
1195 'String Ensemble 2', 'Synth Strings 1', 'Synth Strings 2', 'Choir Aahs', 'Voice Oohs', 'Synth Voice',
1196 'Orchestra Hit', 'Trumpet', 'Trombone', 'Tuba', 'Muted Trumpet', 'French Horn', 'Brass Section', 'Synth Brass 1',
1197 'Synth Brass 2', 'Soprano Sax', 'Alto Sax', 'Tenor Sax', 'Baritone Sax', 'Oboe', 'English Horn', 'Bassoon',
1198 'Clarinet', 'Piccolo', 'Flute', 'Recorder', 'Pan Flute', 'Blown Bottle', 'Shakuhachi', 'Whistle', 'Ocarina',
1199 'Lead 1 (square)', 'Lead 2 (sawtooth)', 'Lead 3 (calliope)', 'Lead 4 (chiff)', 'Lead 5 (charang)',
1200 'Lead 6 (voice)', 'Lead 7 (fifths)', 'Lead 8 (bass + lead)', 'Pad 1 (new age)', 'Pad 2 (warm)',
1201 'Pad 3 (polysynth)', 'Pad 4 (choir)', 'Pad 5 (bowed)', 'Pad 6 (metallic)', 'Pad 7 (halo)', 'Pad 8 (sweep)',
1202 'FX 1 (rain)', 'FX 2 (soundtrack)', 'FX 3 (crystal)', 'FX 4 (atmosphere)', 'FX 5 (brightness)', 'FX 6 (goblins)',
1203 'FX 7 (echoes)', 'FX 8 (sci-fi)', 'Sitar', 'Banjo', 'Shamisen', 'Koto', 'Kalimba', 'Bagpipe', 'Fiddle', 'Shanai',
1204 'Tinkle Bell', 'Agogo', 'Steel Drums', 'Woodblock', 'Taiko Drum', 'Melodic Tom', 'Synth Drum', 'Reverse Cymbal',
1205 'Guitar Fret Noise', 'Breath Noise', 'Seashore', 'Bird Tweet', 'Telephone Ring', 'Helicopter', 'Applause',
1206 'Gunshot',
1207 );
1208  
1209 17 my %DRUM_NAMES = (
1210 35 => 'Acoustic Bass Drum', 36 => 'Bass Drum 1', 37 => 'Side Stick', 38 => 'Acoustic Snare', 39 => 'Hand Clap',
1211 40 => 'Electric Snare', 41 => 'Low Floor Tom', 42 => 'Closed Hi-Hat', 43 => 'High Floor Tom', 44 => 'Pedal Hi-Hat',
1212 45 => 'Low Tom', 46 => 'Open Hi-Hat', 47 => 'Low-Mid Tom', 48 => 'Hi-Mid Tom', 49 => 'Crash Cymbal 1',
1213 50 => 'High Tom', 51 => 'Ride Cymbal 1', 52 => 'Chinese Cymbal', 53 => 'Ride Bell', 54 => 'Tambourine',
1214 55 => 'Splash Cymbal', 56 => 'Cowbell', 57 => 'Crash Cymbal 2', 58 => 'Vibraslap', 59 => 'Ride Cymbal 2',
1215 60 => 'Hi Bongo', 61 => 'Low Bongo', 62 => 'Mute Hi Conga', 63 => 'Open Hi Conga', 64 => 'Low Conga',
1216 65 => 'High Timbale', 66 => 'Low Timbale', 67 => 'High Agogo', 68 => 'Low Agogo', 69 => 'Cabasa', 70 => 'Maracas',
1217 71 => 'Short Whistle', 72 => 'Long Whistle', 73 => 'Short Guiro', 74 => 'Long Guiro', 75 => 'Claves',
1218 76 => 'Hi Wood Block', 77 => 'Low Wood Block', 78 => 'Mute Cuica', 79 => 'Open Cuica', 80 => 'Mute Triangle',
1219 81 => 'Open Triangle',
1220 );
1221  
1222 135 ▶sub program_name ($number, $bank = 0) {
Subroutine program_name: called CC=6 SCAR=18.6
Pod documented
1223 135 ▶ return $VARIATION{$bank}{$number}[0] if $bank && $VARIATION{$bank} && $VARIATION{$bank}{$number};
Branch: 1 branch
BranchTrueFalseTotal
if $bank and $VARIATION{$bank} and $VARIATION{$bank}{$number} 2 133 135
Condition66%4/6
$bank and $VARIATION{$bank} and $VARIATION{$bank}{$number}
!ll&&!rl&&r
13302
$bank and $VARIATION{$bank}
!ll&&!rl&&r
13302
MC/DC33%1/3
$bank and $VARIATION{$bank} and $VARIATION{$bank}{$number}
$bank $VARIATION{$bank} $VARIATION{$bank}{$number}
Truth table50%2/4
A and B and C
A= $bankB= $VARIATION{$bank}C= $VARIATION{$bank}{$number}
ABCresult
0XX0
10X0
1100
1111
1224 133 ▶ return $PROGRAM_NAMES[$number] // "Program $number";
Condition50%1/2
$PROGRAM_NAMES[$number] // "Program $number"
l!l
1330
MC/DC0%0/1
$PROGRAM_NAMES[$number] // "Program $number"
$PROGRAM_NAMES[$number]
Truth table50%1/2
A
A= $PROGRAM_NAMES[$number]
Aresult
11
00
1225 }
1226 47 ▶sub drum_name ($key) { return $DRUM_NAMES{$key} // "Drum $key" }
Subroutine drum_name: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
$DRUM_NAMES{$key} // "Drum $key"
l!l
470
MC/DC0%0/1
$DRUM_NAMES{$key} // "Drum $key"
$DRUM_NAMES{$key}
Truth table50%1/2
A
A= $DRUM_NAMES{$key}
Aresult
11
00
1227 0 ▶sub kit_name ($kit) { return $KIT{$kit} ? $KIT{$kit}[0] : "Kit $kit" }
Subroutine kit_name: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$KIT{$kit} ? : 0 0 0
1228 4 ▶sub program_names () { return [@PROGRAM_NAMES] }
Subroutine program_names: called CC=1 SCAR=0.0
Pod documented
1229 5 ▶sub drum_names () { return {%DRUM_NAMES} }
Subroutine drum_names: called CC=1 SCAR=0.0
Pod documented
1230  
1231 # The kits: { number => { name, keys (its own, the others the standard kit's) } }.
1232 6 ▶sub kits () {
Subroutine kits: called CC=1 SCAR=0.0
Pod documented
1233 6 return { map { $_ => { name => $KIT{$_}[0], keys => [ sort { $a <=> $b } keys %{ $KIT{$_}[1] } ] } } keys %KIT };
1234 }
1235  
1236 # The variations: [ GS bank, program, name ], in the order of the programs.
1237 5 ▶sub variations () {
Subroutine variations: called CC=3 SCAR=11.0
Pod documented
1238 5 my @all;
1239 5 for my $bank (keys %VARIATION) {
1240 15 push @all, map { [ 0 + $bank, 0 + $_, $VARIATION{$bank}{$_}[0] ] } keys %{ $VARIATION{$bank} };
1241 }
1242 5 ▶ return [ sort { $a->[1] <=> $b->[1] || $a->[0] <=> $b->[0] } @all ];
Condition66%2/3
$Peta::Synth::Patch::a->[1] <=> $Peta::Synth::Patch::b->[1] || $Peta::Synth::Patch::a->[0] <=> $Peta::Synth::Patch::b->[0]
l!l&&r!l&&!r
55950
MC/DC0%0/2
$Peta::Synth::Patch::a->[1] <=> $Peta::Synth::Patch::b->[1] || $Peta::Synth::Patch::a->[0] <=> $Peta::Synth::Patch::b->[0]
$Peta::Synth::Patch::a->[1] <=> $Peta::Synth::Patch::b->[1] $Peta::Synth::Patch::a->[0] <=> $Peta::Synth::Patch::b->[0]
Truth table66%2/3
A || B
A= $Peta::Synth::Patch::a->[1] <=> $Peta::Synth::Patch::b->[1]B= $Peta::Synth::Patch::a->[0] <=> $Peta::Synth::Patch::b->[0]
ABresult
1X1
011
000
1243 }
1244  
1245 17 1;
1246  
1247 __END__
« lib/Peta/Synth/FFT.pm ↑ Summary lib/Peta/MP3/Encode/Filterbank/PDL.pm »