89519c1crash: extension notes when the arms are fully extendedJeremy Magland 1// How many ringing extension notes can this device render? Instruments like Chaos gong are costly
f7d91baAdd composition 4: crashJeremy Magland 2// per ringing voice (strongly coupled modes can't be culled), so measure one voice's cost in a
97bd308Make streamed audio robust: voice caps, 2 s buffer, soft underrunsJeremy Magland 3// render worker (see instruments/stream/capacity.ts) and allow as many voices as fit the budget.
f7d91baAdd composition 4: crashJeremy Magland 4
5import { DEFAULTS } from "@modal-synth/engine/params.ts";
6import { PRESETS } from "@modal-synth/presets.ts";
7import type { Params } from "../../core/params.ts";
8import { parseModalPreset } from "../../instruments/modal.ts";
97bd308Make streamed audio robust: voice caps, 2 s buffer, soft underrunsJeremy Magland 9import { VOICE_BUDGET, voiceCost, voicesThatFit } from "../../instruments/stream/capacity.ts";
f7d91baAdd composition 4: crashJeremy Magland 10
11export interface VoiceCapacity {
12 cap: number; // voices allowed
13 perVoice: number; // measured load of one ringing voice
14}
16function sound(P: Params): Params | null {
89519c1crash: extension notes when the arms are fully extendedJeremy Magland 17 const name = P.extInstrument as string;
19 const p = name === "modal: custom" ? parseModalPreset(P.modalCustom as string) : PRESETS.find((x) => `modal: ${x.name}` === name)?.p;
20 return { ...DEFAULTS, ...(p ?? {}) };
21}
5d7ea1acrash: fixed-pitch 'bottom notes' (no longer called crashes)Jeremy Magland 23export async function overlapCapacity(P: Params, sampleRate: number, wanted: number): Promise<VoiceCapacity> {
25 if (!s) return { cap: wanted, perVoice: 0 };
97bd308Make streamed audio robust: voice caps, 2 s buffer, soft underrunsJeremy Magland 26 const perVoice = await voiceCost({ ...s, voices: 1 }, sampleRate);
27 return { cap: voicesThatFit(perVoice, wanted), perVoice };
97bd308Make streamed audio robust: voice caps, 2 s buffer, soft underrunsJeremy Magland 30export const OVERLAP_BUDGET = VOICE_BUDGET;