31 const clap_plugin_descriptor* mDesc;
32 const clap_host* mHost;
38using ClapPluginHelper = clap::helpers::Plugin<clap::helpers::MisbehaviourHandler::Terminate, clap::helpers::CheckingLevel::Maximal>;
39using ClapHost = clap::helpers::HostProxy<clap::helpers::MisbehaviourHandler::Terminate, clap::helpers::CheckingLevel::Maximal>;
41using ClapPluginHelper = clap::helpers::Plugin<clap::helpers::MisbehaviourHandler::Ignore, clap::helpers::CheckingLevel::None>;
42using ClapHost = clap::helpers::HostProxy<clap::helpers::MisbehaviourHandler::Ignore, clap::helpers::CheckingLevel::None>;
49 ,
public ClapPluginHelper
53 enum class Type { Begin, Value, End };
61 ParamToHost(Type type,
int idx,
double value)
67 uint32_t idx()
const {
return static_cast<uint32_t
>(mIdx); }
68 double value()
const {
return mValue; }
73 case Type::Begin:
return CLAP_EVENT_PARAM_GESTURE_BEGIN;
74 case Type::End:
return CLAP_EVENT_PARAM_GESTURE_END;
76 default:
return CLAP_EVENT_PARAM_VALUE;
86 IPlugCLAP(
const InstanceInfo& info,
const Config& config);
92 bool EditorResize(
int viewWidth,
int viewHeight)
override;
102 bool init()
noexcept override;
103 bool activate(
double sampleRate, uint32_t minFrameCount, uint32_t maxFrameCount)
noexcept override;
104 void deactivate()
noexcept override;
105 bool startProcessing()
noexcept override {
return true; }
106 void stopProcessing()
noexcept override {}
107 void reset()
noexcept override {
OnReset(); }
108 clap_process_status process(
const clap_process* pProcess)
noexcept override;
111 bool implementsLatency()
const noexcept override {
return true; }
112 uint32_t latencyGet()
const noexcept override {
return GetLatency(); }
115 bool implementsTail()
const noexcept override {
return true; }
116 uint32_t tailGet()
const noexcept override;
119 bool implementsRender()
const noexcept override {
return true; }
120 bool renderHasHardRealtimeRequirement()
noexcept override {
return false; }
121 bool renderSetMode(clap_plugin_render_mode mode)
noexcept override;
124 bool implementsState()
const noexcept override {
return true; }
125 bool stateSave(
const clap_ostream* pStream)
noexcept override;
126 bool stateLoad(
const clap_istream* pStream)
noexcept override;
129 bool implementsAudioPorts()
const noexcept override;
130 uint32_t audioPortsCount(
bool isInput)
const noexcept override;
131 bool audioPortsInfo(uint32_t index,
bool isInput, clap_audio_port_info* pInfo)
const noexcept override;
134 bool implementsAudioPortsConfig()
const noexcept override;
135 uint32_t audioPortsConfigCount()
const noexcept override;
136 bool audioPortsGetConfig(uint32_t index, clap_audio_ports_config* pConfig)
const noexcept override;
137 bool audioPortsSetConfig(clap_id configIdx)
noexcept override;
141 uint32_t notePortsCount(
bool isInput)
const noexcept override;
142 bool notePortsInfo(uint32_t index,
bool isInput, clap_note_port_info* pInfo)
const noexcept override;
145 bool implementsParams()
const noexcept override {
return true; }
146 uint32_t paramsCount()
const noexcept override {
return NParams(); }
148 bool paramsInfo(uint32_t paramIdx, clap_param_info* pInfo)
const noexcept override;
150 bool paramsValue(clap_id paramIdx,
double* pValue)
noexcept override;
151 bool paramsValueToText(clap_id paramIdx,
double value,
char* display, uint32_t size)
noexcept override;
152 bool paramsTextToValue(clap_id paramIdx,
const char* display,
double* pValue)
noexcept override;
154 void paramsFlush(
const clap_input_events* pInputParamChanges,
const clap_output_events* pOutputParamChanges)
noexcept override;
155 bool isValidParamId(clap_id paramIdx)
const noexcept override {
return paramIdx < NParams(); }
158 bool implementsGui()
const noexcept override;
159 bool guiCreate(
const char* api,
bool isFloating)
noexcept override;
160 void guiDestroy()
noexcept override;
162 bool guiSetScale(
double scale)
noexcept override;
163 bool guiShow()
noexcept override;
164 bool guiHide()
noexcept override;
165 bool guiGetSize(uint32_t* pWidth, uint32_t* pHeight)
noexcept override;
167 bool guiCanResize()
const noexcept override;
168 bool guiAdjustSize(uint32_t* pWidth, uint32_t* pHeight)
noexcept override;
169 bool guiSetSize(uint32_t width, uint32_t height)
noexcept override;
172 bool guiIsApiSupported(
const char* api,
bool isFloating)
noexcept override;
173 bool guiSetParent(
const clap_window* pWindow)
noexcept override;
176 bool GUIWindowAttach(
void* parent)
noexcept;
179 void FlushParamsIfNeeded();
182 void ProcessInputEvents(
const clap_input_events* pInputEvents)
noexcept;
183 void ProcessOutputParams(
const clap_output_events* pOutputParamChanges)
noexcept;
184 void ProcessOutputEvents(
const clap_output_events* pOutputEvents,
int nFrames)
noexcept;
187 ClapHost& GetClapHost() {
return _host; }
190 void SetDefaultConfig();
191 int RequiredChannels()
const;
192 uint32_t NBuses(
ERoute direction)
const;
193 uint32_t NChannels(
ERoute direction, uint32_t bus)
const;
194 uint32_t NBuses(
ERoute direction,
int configIdx)
const;
195 uint32_t NChannels(
ERoute direction, uint32_t bus,
int configIdx)
const;
200 WDL_TypedBuf<float *> mAudioIO32;
201 WDL_TypedBuf<double *> mAudioIO64;
204 bool mHostHasTail =
false;
205 bool mTailUpdate =
false;
206 bool mLatencyUpdate =
false;
208 void* mWindow =
nullptr;
209 bool mGUIOpen =
false;
212IPlugCLAP* MakePlug(
const InstanceInfo& info);
A class to help with queuing timestamped MIDI messages.
The base class of an IPlug plug-in, which interacts with the different plug-in APIs.
CLAP API base class for an IPlug plug-in.
bool SendSysEx(const ISysEx &msg) override
Send a single MIDI System Exclusive (SysEx) message // TODO: info about what thread should this be ca...
void InformHostOfParamChange(int idx, double normalizedValue) override
Implemented by the API class, called by the UI via SetParameterValue() with the value of a parameter ...
void SetTailSize(int tailSize) override
Call this method if you need to update the tail size at runtime, for example if the decay time of you...
void SetLatency(int samples) override
Call this if the latency of your plug-in changes after initialization (perhaps from OnReset() ) This ...
bool EditorResize(int viewWidth, int viewHeight) override
Implementations call into the APIs resize hooks returns a bool to indicate whether the DAW or plugin ...
void BeginInformHostOfParamChange(int idx) override
Implemented by the API class, called by the UI (or by a delegate) at the beginning of a parameter cha...
bool SendMidiMsg(const IMidiMsg &msg) override
Send a single MIDI message // TODO: info about what thread should this be called on or not called on!
void EndInformHostOfParamChange(int idx) override
Implemented by the API class, called by the UI (or by a delegate) at the end of a parameter change ge...
The base class for IPlug Audio Processing.
virtual void OnReset()
Override this method in your plug-in class to do something prior to playback etc.
A lock-free SPSC queue used to transfer data between threads based on MLQueue.h by Randy Jones based ...
ERoute
Used to identify whether a bus/channel connection is an input or an output.
Encapsulates a MIDI message and provides helper functions.
A struct for dealing with SysEx messages.