MVP
This commit is contained in:
parent
f2aae2a502
commit
64b045fa77
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#define DISTRHO_PLUGIN_HAS_UI 1
|
#define DISTRHO_PLUGIN_HAS_UI 1
|
||||||
#define DISTRHO_PLUGIN_IS_RT_SAFE 1
|
#define DISTRHO_PLUGIN_IS_RT_SAFE 1
|
||||||
#define DISTRHO_PLUGIN_NUM_INPUTS 2
|
#define DISTRHO_PLUGIN_NUM_INPUTS 0
|
||||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
|
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
|
||||||
#define DISTRHO_PLUGIN_WANT_TIMEPOS 1
|
#define DISTRHO_PLUGIN_WANT_TIMEPOS 1
|
||||||
#define DISTRHO_UI_USE_NANOVG 1
|
#define DISTRHO_UI_USE_NANOVG 1
|
||||||
|
@ -24,6 +24,7 @@ enum Parameters {
|
||||||
kParameterTabletY,
|
kParameterTabletY,
|
||||||
kParameterTabletZ,
|
kParameterTabletZ,
|
||||||
kParameterTabletPressure,
|
kParameterTabletPressure,
|
||||||
|
kParameterTime,
|
||||||
kParameterCount
|
kParameterCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,101 +2,131 @@
|
||||||
|
|
||||||
START_NAMESPACE_DISTRHO
|
START_NAMESPACE_DISTRHO
|
||||||
|
|
||||||
class TabPlugin : public Plugin
|
class TabPlugin : public Plugin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TabPlugin()
|
TabPlugin()
|
||||||
: Plugin(kParameterCount, 0, 0)
|
: Plugin(kParameterCount, 0, 0),
|
||||||
{
|
sampleRate(getSampleRate())
|
||||||
// clear all parameters
|
{
|
||||||
std::memset(fParameters, 0, sizeof(float) * kParameterCount);
|
// clear all parameters
|
||||||
|
std::memset(fParameters, 0, sizeof(float) * kParameterCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char* getLabel() const override { return "yaw-tab"; }
|
const char* getLabel() const override { return "yaw-tab"; }
|
||||||
const char* getDescription() const override { return "Drawing tablet synth UI"; }
|
const char* getDescription() const override { return "Drawing tablet synth UI"; }
|
||||||
const char* getMaker() const override { return "yaw-audio"; }
|
const char* getMaker() const override { return "yaw-audio"; }
|
||||||
const char* getHomePage() const override { return "https://yaw.man/plugins/yaw-tab"; }
|
const char* getHomePage() const override { return "https://yaw.man/plugins/yaw-tab"; }
|
||||||
const char* getLicense() const override { return "ISC"; }
|
const char* getLicense() const override { return "ISC"; }
|
||||||
uint32_t getVersion() const override { return d_version(1, 0, 0); }
|
uint32_t getVersion() const override { return d_version(1, 0, 0); }
|
||||||
int64_t getUniqueId() const override { return d_cconst('y', 'w', 't', 'b'); }
|
int64_t getUniqueId() const override { return d_cconst('y', 'w', 't', 'b'); }
|
||||||
|
|
||||||
|
|
||||||
void initParameter(uint32_t index, Parameter& parameter) override
|
void initParameter(uint32_t index, Parameter& parameter) override
|
||||||
{
|
{
|
||||||
parameter.hints = kParameterIsAutomable | kParameterIsOutput;
|
parameter.hints = kParameterIsAutomable;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 16777216.0f;
|
parameter.ranges.max = 16777216.0f;
|
||||||
|
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case kParameterTabletX:
|
case kParameterTabletX:
|
||||||
parameter.name = "x";
|
parameter.name = "x";
|
||||||
parameter.symbol = "x";
|
parameter.symbol = "x";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 999.0f;
|
parameter.ranges.max = 999.0f;
|
||||||
break;
|
break;
|
||||||
case kParameterTabletY:
|
case kParameterTabletY:
|
||||||
parameter.name = "y";
|
parameter.name = "y";
|
||||||
parameter.symbol = "y";
|
parameter.symbol = "y";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 999.0f;
|
parameter.ranges.max = 999.0f;
|
||||||
break;
|
break;
|
||||||
case kParameterTabletZ:
|
case kParameterTabletZ:
|
||||||
parameter.name = "z";
|
parameter.name = "z";
|
||||||
parameter.symbol = "z";
|
parameter.symbol = "z";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 999.0f;
|
parameter.ranges.max = 999.0f;
|
||||||
break;
|
break;
|
||||||
case kParameterTabletPressure:
|
case kParameterTabletPressure:
|
||||||
parameter.name = "p";
|
parameter.name = "p";
|
||||||
parameter.symbol = "p";
|
parameter.symbol = "p";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 999.0f;
|
parameter.ranges.max = 999.0f;
|
||||||
break;
|
break;
|
||||||
}
|
case kParameterTime:
|
||||||
}
|
parameter.name = "t";
|
||||||
|
parameter.symbol = "t";
|
||||||
|
parameter.ranges.min = 0.0f;
|
||||||
|
parameter.ranges.max = 999.0f;
|
||||||
|
parameter.hints |= kParameterIsOutput;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float getParameterValue(uint32_t index) const override
|
void sampleRateChanged(double newRate) override
|
||||||
{
|
{
|
||||||
return fParameters[index];
|
sampleRate = newRate;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
float getParameterValue(uint32_t index) const override
|
||||||
|
{
|
||||||
|
return fParameters[index];
|
||||||
|
|
||||||
void setParameterValue(uint32_t, float) override
|
}
|
||||||
{
|
|
||||||
// this is only called for input parameters, which we have none of.
|
|
||||||
}
|
|
||||||
|
|
||||||
void run(const float** inputs, float** outputs, uint32_t frames) override
|
void setParameterValue(uint32_t idx, float val) override
|
||||||
{
|
{
|
||||||
/**
|
fParameters[idx] = val;
|
||||||
This plugin does nothing, it just demonstrates information usage.
|
switch (idx) {
|
||||||
So here we directly copy inputs over outputs, leaving the audio untouched.
|
case kParameterTabletX:
|
||||||
We need to be careful in case the host re-uses the same buffer for both inputs and outputs.
|
period = 0.02f * (0.001f * val) * sampleRate;
|
||||||
*/
|
break;
|
||||||
if (outputs[0] != inputs[0])
|
case kParameterTabletY:
|
||||||
std::memcpy(outputs[0], inputs[0], sizeof(float) * frames);
|
break;
|
||||||
|
case kParameterTabletZ:
|
||||||
|
break;
|
||||||
|
case kParameterTabletPressure:
|
||||||
|
volume = 0.001f * val;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (outputs[1] != inputs[1])
|
void run(const float** inputs, float** outputs, uint32_t frames) override
|
||||||
std::memcpy(outputs[1], inputs[1], sizeof(float) * frames);
|
{
|
||||||
|
|
||||||
// get time position
|
for (uint32_t i = 0; i < frames; ++i) {
|
||||||
const TimePosition& timePos(getTimePosition());
|
counter++;
|
||||||
fParameters[kParameterTabletPressure] = timePos.bbt.tick;
|
if (counter > period) {
|
||||||
}
|
outputs[0][i] = outputs[1][i] = volume;
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outputs[0][i] = outputs[1][i] = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force UI to repaint via parameter change callback.
|
||||||
|
const TimePosition& timePos(getTimePosition());
|
||||||
|
fParameters[kParameterTime] = timePos.bbt.tick;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float fParameters[kParameterCount];
|
float fParameters[kParameterCount];
|
||||||
|
float period = 0.f;
|
||||||
|
float counter = 0.f;
|
||||||
|
float volume = 0.f;
|
||||||
|
float sampleRate;
|
||||||
|
|
||||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TabPlugin)
|
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TabPlugin)
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugin* createPlugin()
|
Plugin* createPlugin()
|
||||||
{
|
{
|
||||||
return new TabPlugin();
|
return new TabPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
END_NAMESPACE_DISTRHO
|
END_NAMESPACE_DISTRHO
|
||||||
|
|
|
@ -34,7 +34,10 @@ protected:
|
||||||
void parameterChanged(uint32_t index, float value) override
|
void parameterChanged(uint32_t index, float value) override
|
||||||
{
|
{
|
||||||
|
|
||||||
fParameters[index] = value;
|
if (index != kParameterTime) {
|
||||||
|
fParameters[index] = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Lire donnés de la tablet
|
//Lire donnés de la tablet
|
||||||
tab.NewPacket();
|
tab.NewPacket();
|
||||||
|
@ -49,6 +52,10 @@ protected:
|
||||||
fParameters[kParameterTabletZ] = z;
|
fParameters[kParameterTabletZ] = z;
|
||||||
fParameters[kParameterTabletPressure] = p;
|
fParameters[kParameterTabletPressure] = p;
|
||||||
|
|
||||||
|
setParameterValue(kParameterTabletX, x);
|
||||||
|
setParameterValue(kParameterTabletY, y);
|
||||||
|
setParameterValue(kParameterTabletZ, z);
|
||||||
|
setParameterValue(kParameterTabletPressure, p);
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue