11#include "IPlugWasmUI.h"
15#include <emscripten.h>
16#include <emscripten/bind.h>
19using namespace emscripten;
21IPlugWasmUI::IPlugWasmUI(
const InstanceInfo& info,
const Config& config)
24 mControllerName.SetFormatted(32,
"%s_Hybrid", GetPluginName());
27void IPlugWasmUI::SendParameterValueFromUI(
int paramIdx,
double value)
31 if (typeof window.iPlugController !==
'undefined') {
32 window.iPlugController.setParam($0, $1);
34 console.warn(
'IPlugWasmUI: controller not ready');
39 IPlugAPIBase::SendParameterValueFromUI(paramIdx, value);
42void IPlugWasmUI::SendMidiMsgFromUI(
const IMidiMsg& msg)
45 if (typeof window.iPlugController !==
'undefined') {
46 window.iPlugController.sendMidi($0, $1, $2);
48 console.warn(
'IPlugWasmUI: controller not ready');
50 }, msg.mStatus, msg.mData1, msg.mData2);
53void IPlugWasmUI::SendSysexMsgFromUI(
const ISysEx& msg)
56 if (typeof window.iPlugController !==
'undefined') {
57 var data = new Uint8Array($1);
58 data.set(HEAPU8.subarray($0, $0 + $1));
59 window.iPlugController.sendSysex(data);
61 console.warn(
'IPlugWasmUI: controller not ready');
63 },
reinterpret_cast<intptr_t
>(msg.mData), msg.mSize);
66void IPlugWasmUI::SendArbitraryMsgFromUI(
int msgTag,
int ctrlTag,
int dataSize,
const void* pData)
68 if (dataSize > 0 && pData)
71 if (typeof window.iPlugController !==
'undefined') {
72 var data = new Uint8Array($2);
73 data.set(HEAPU8.subarray($3, $3 + $2));
74 window.iPlugController.sendArbitraryMsg($0, $1, data);
76 console.warn(
'IPlugWasmUI: controller not ready');
78 }, msgTag, ctrlTag, dataSize,
reinterpret_cast<intptr_t
>(pData));
83 if (typeof window.iPlugController !==
'undefined') {
84 window.iPlugController.sendArbitraryMsg($0, $1, null);
90void IPlugWasmUI::SendDSPIdleTick()
93 if (typeof window.iPlugController !==
'undefined') {
94 window.iPlugController.sendIdleTick();
100extern std::unique_ptr<iplug::IPlugWasmUI> gPlug;
103static void _SendParameterValueFromDelegate(
int paramIdx,
double normalizedValue)
105 gPlug->SendParameterValueFromDelegate(paramIdx, normalizedValue,
true);
108static void _SendControlValueFromDelegate(
int ctrlTag,
double normalizedValue)
110 gPlug->SendControlValueFromDelegate(ctrlTag, normalizedValue);
113static void _SendControlMsgFromDelegate(
int ctrlTag,
int msgTag,
int dataSize, uintptr_t pData)
115 const uint8_t* pDataPtr =
reinterpret_cast<uint8_t*
>(pData);
116 gPlug->SendControlMsgFromDelegate(ctrlTag, msgTag, dataSize, pDataPtr);
119static void _SendArbitraryMsgFromDelegate(
int msgTag,
int dataSize, uintptr_t pData)
121 const uint8_t* pDataPtr =
reinterpret_cast<uint8_t*
>(pData);
122 gPlug->SendArbitraryMsgFromDelegate(msgTag, dataSize, pDataPtr);
125static void _SendMidiMsgFromDelegate(
int status,
int data1,
int data2)
127 IMidiMsg msg{0, (uint8_t)status, (uint8_t)data1, (uint8_t)data2};
128 gPlug->SendMidiMsgFromDelegate(msg);
131static void _SendSysexMsgFromDelegate(
int dataSize, uintptr_t pData)
133 const uint8_t* pDataPtr =
reinterpret_cast<uint8_t*
>(pData);
134 ISysEx msg(0, pDataPtr, dataSize);
135 gPlug->SendSysexMsgFromDelegate(msg);
138static void _StartIdleTimer()
140 gPlug->CreateTimer();
143static void _OnParentWindowResize(
int width,
int height)
146 gPlug->OnParentWindowResize(width, height);
150 function(
"SPVFD", &_SendParameterValueFromDelegate);
151 function(
"SCVFD", &_SendControlValueFromDelegate);
152 function(
"SCMFD", &_SendControlMsgFromDelegate);
153 function(
"SAMFD", &_SendArbitraryMsgFromDelegate);
154 function(
"SMMFD", &_SendMidiMsgFromDelegate);
155 function(
"SSMFD", &_SendSysexMsgFromDelegate);
156 function(
"StartIdleTimer", &_StartIdleTimer);
157 function(
"OnParentWindowResize", &_OnParentWindowResize);
The base class of an IPlug plug-in, which interacts with the different plug-in APIs.
Hybrid UI class - IGraphics side for split DSP/UI builds.
Encapsulates a MIDI message and provides helper functions.
A struct for dealing with SysEx messages.