Files
sizzletracker-android/ios/core/include/sizzle/Instrument.hpp
T
ReactorcoremeltdownandClaude Opus 5.5 7f231c8f79 iOS 0.2.0: instruments as AUv3, in-app host with keyboard, MIDI in and benchmark
Shared SizzleDeviceAU base for effects and instruments; sizzle::Instrument voice
pools; Android's factory presets generated into the specs header; the app hosts
every device in-process (no dependence on the system plugin registry).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 22:17:47 +01:00

51 lines
2.0 KiB
C++

// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <memory>
#include "sizzle/Params.hpp"
namespace sizzle {
namespace sampler { class SampleStore; }
/**
* One playable instrument: a pool of voices for a ToolboxType, the way AudioEngine
* plays one mixer channel's instrument (8 voices, a free voice first, else the
* round-robin one; synth voices are cut when stolen, sample voices declick).
* Used by the AUv3 instruments and the in-app host until the full engine is ported.
*
* Threads: construct and call update()/noteOn()/noteOff()/render() from the audio
* thread only (the AU wrapper hands parameter changes over itself). No allocation
* after construction.
*/
class Instrument {
public:
virtual ~Instrument() = default;
/** New settings (and tempo): rebuild the patch, and let held notes follow it
* where the Kotlin engine does (synth voices take the new patch). */
virtual void update(const Params &p, float tempoBpm) = 0;
virtual void noteOn(int midi, int velocity) = 0;
/** Release the held note(s) at [midi]. */
virtual void noteOff(int midi) = 0;
/** Release everything (MIDI all-notes-off, transport stop). */
virtual void allNotesOff() = 0;
/** Hard stop, no release tails. */
virtual void kill() = 0;
/** Before each render block of [frames]: advances the Morph Pad's shared clock
* and lets the sample store reclaim memory. */
virtual void blockStart(int frames) = 0;
/** One mono output sample. */
virtual float render() = 0;
static constexpr int POLYPHONY = 8;
/** The instrument for ToolboxType [type] (NES_SYNTH, MORPH_PAD, WAVETABLE,
* GRAIN_CLOUD, SAMPLER, SOUNDFONT), or nullptr. [store] supplies samples for
* the Sampler, SF2/XI loader and Grain Cloud custom sources (may be null:
* those then stay silent); it must outlive the instrument. */
static std::unique_ptr<Instrument> create(const char *type, int sampleRate, sampler::SampleStore *store);
};
} // namespace sizzle