iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IPlugWasmDSP.h
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#ifndef _IPLUG_HYBRID_DSP_
12#define _IPLUG_HYBRID_DSP_
13
14#include "IPlugAPIBase.h"
15#include "IPlugProcessor.h"
16
17BEGIN_IPLUG_NAMESPACE
18
20struct InstanceInfo
21{};
22
34 , public IPlugProcessor
35{
36public:
37 IPlugWasmDSP(const InstanceInfo& info, const Config& config);
38 virtual ~IPlugWasmDSP();
39
41 void SetInstanceId(int instanceId);
42
44 int GetInstanceId() const { return mInstanceId; }
45
49 void Init(int sampleRate, int blockSize);
50
55 void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override;
56
57 // Message handlers - called from JS port.onmessage
58 void OnParamMessage(int paramIdx, double value);
59 void OnMidiMessage(int status, int data1, int data2);
60 void OnSysexMessage(const uint8_t* pData, int size);
61 void OnArbitraryMessage(int msgTag, int ctrlTag, int dataSize, const void* pData);
62
64 void OnIdleTick();
65
66 // IPlugProcessor
67 void SetLatency(int samples) override {}
68 bool SendMidiMsg(const IMidiMsg& msg) override;
69 bool SendSysEx(const ISysEx& msg) override;
70
71 // IEditorDelegate - send to UI via postMessage
72 void SendControlValueFromDelegate(int ctrlTag, double normalizedValue) override;
73 void SendControlMsgFromDelegate(int ctrlTag, int msgTag, int dataSize, const void* pData) override;
74 void SendParameterValueFromDelegate(int paramIdx, double value, bool normalized) override;
75 void SendArbitraryMsgFromDelegate(int msgTag, int dataSize = 0, const void* pData = nullptr) override;
76 void SendMidiMsgFromDelegate(const IMidiMsg& msg) override;
77
79 int GetNumInputChannels() const { return MaxNChannels(ERoute::kInput); }
80
82 int GetNumOutputChannels() const { return MaxNChannels(ERoute::kOutput); }
83
85 bool IsPlugInstrument() const { return IsInstrument(); }
86
87private:
88 int mInstanceId = 0;
89};
90
91IPlugWasmDSP* MakePlug(const InstanceInfo& info);
92
93END_IPLUG_NAMESPACE
94
95#endif // _IPLUG_HYBRID_DSP_
The base class of an IPlug plug-in, which interacts with the different plug-in APIs.
Definition: IPlugAPIBase.h:43
The base class for IPlug Audio Processing.
bool IsInstrument() const
int MaxNChannels(ERoute direction) const
Hybrid DSP class - AudioWorklet processor for split DSP/UI builds.
Definition: IPlugWasmDSP.h:35
void Init(int sampleRate, int blockSize)
Initialize the DSP processor.
bool SendSysEx(const ISysEx &msg) override
Send a single MIDI System Exclusive (SysEx) message // TODO: info about what thread should this be ca...
void SetInstanceId(int instanceId)
Set the instance ID (called after construction by createInstance binding)
int GetNumOutputChannels() const
Get the number of output channels.
Definition: IPlugWasmDSP.h:82
void OnIdleTick()
Called on idle tick to flush queued messages to UI.
int GetInstanceId() const
Get the instance ID.
Definition: IPlugWasmDSP.h:44
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!
int GetNumInputChannels() const
Get the number of input channels.
Definition: IPlugWasmDSP.h:79
bool IsPlugInstrument() const
Check if plugin is an instrument (synth)
Definition: IPlugWasmDSP.h:85
void SetLatency(int samples) override
Call this if the latency of your plug-in changes after initialization (perhaps from OnReset() ) This ...
Definition: IPlugWasmDSP.h:67
void ProcessBlock(sample **inputs, sample **outputs, int nFrames) override
Process a block of audio.
Encapsulates a MIDI message and provides helper functions.
Definition: IPlugMidi.h:31
A struct for dealing with SysEx messages.
Definition: IPlugMidi.h:539