65 lines
2.7 KiB
C++
65 lines
2.7 KiB
C++
// native_bridge/include/Vst3Instrument.h
|
|
// VST3 host instrument (A7). Compiled ALWAYS; the real vst3sdk wiring is
|
|
// inside #ifdef HAVE_VST3SDK (set by CMake when the vst3sdk submodule is
|
|
// present). Without the SDK the class degrades to a no-op stub so the bridge
|
|
// still builds for SF2/SF3/SFZ.
|
|
#ifndef VST3_INSTRUMENT_H
|
|
#define VST3_INSTRUMENT_H
|
|
|
|
#include "INativeInstrument.h"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class Vst3Instrument : public INativeInstrument {
|
|
public:
|
|
Vst3Instrument();
|
|
~Vst3Instrument() override;
|
|
|
|
bool loadPlugin(const std::string& path, double sampleRate);
|
|
|
|
bool init(double sampleRate, uint32_t maxBlockSize) override;
|
|
void selectProgram(uint32_t channel, uint32_t bank, uint32_t program) override;
|
|
void noteOn(uint32_t channel, uint32_t pitch, float velocity, uint32_t sampleOffset) override;
|
|
void noteOff(uint32_t channel, uint32_t pitch, uint32_t sampleOffset) override;
|
|
void controlChange(uint32_t channel, uint32_t cc, uint32_t value) override;
|
|
void programChange(uint32_t channel, uint32_t program) override;
|
|
void pitchBend(uint32_t channel, uint32_t bend14) override;
|
|
bool openGUI(void* parentWindowHandle) override;
|
|
bool reloadForGUI() override;
|
|
bool attachView(void* parentWindowHandle) override;
|
|
// G0.4: keep the preset across GUI reopen (reload() recreates the
|
|
// instance from scratch — without save/restore the plugin resets).
|
|
void captureState();
|
|
void restoreState();
|
|
// G2.1: base64 of [4B BE componentLen][component][4B BE controllerLen][controller]
|
|
// from the last captureState(). Empty when nothing captured.
|
|
std::string serializeState() const override;
|
|
void loadSerializedState(const std::string& base64) override;
|
|
void resizeView(int w, int h) override;
|
|
bool hasAttachedView() const override;
|
|
void closeGUI() override;
|
|
bool reload() override;
|
|
void setChannel(uint32_t ch) { channel_ = ch; }
|
|
bool needsReload() const override { return hasAttachedOnce_ && !guiAttached_; }
|
|
void setReloading(bool on) override { reloading_ = on; }
|
|
void processAudioBlock(float* outputL, float* outputR, uint32_t numSamples) override;
|
|
|
|
private:
|
|
// pimpl: all Steinberg SDK types live in Vst3Instrument.cpp (Vst3HostState).
|
|
void* state_;
|
|
std::string path_;
|
|
double sampleRate_;
|
|
uint32_t maxBlockSize_;
|
|
bool loaded_;
|
|
bool guiAttached_;
|
|
bool hasAttachedOnce_;
|
|
bool reloading_; // guarded by InstrumentEngineManager::mu_ (set via setReloading)
|
|
uint32_t channel_ = 0;
|
|
// G0.4: serialized IComponent/IEditController state captured before reload.
|
|
std::vector<uint8_t> savedComponentState_;
|
|
std::vector<uint8_t> savedControllerState_;
|
|
};
|
|
|
|
#endif // VST3_INSTRUMENT_H
|