19 changes: 14 additions & 5 deletions dpf/distrho/src/DistrhoPluginCLAP.cpp
Expand Up @@ -14,6 +14,14 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/* TODO items:
* CV: write a specification
* INFO: define url, manual url, support url and string version
* PARAMETERS: test parameter triggers
* States: skip DSP/UI only states as appropriate
* UI: expose external-only UIs
*/

#include "DistrhoPluginInternal.hpp"
#include "extra/ScopedPointer.hpp"

Expand Down Expand Up @@ -1070,8 +1078,7 @@ class PluginCLAP : ClapEventQueue
fPlugin.run(audioInputs, audioOutputs, frames);
#endif

// TODO set last frame
flushParameters(nullptr, process->out_events);
flushParameters(nullptr, process->out_events, frames - 1);

fOutputEvents = nullptr;
}
Expand Down Expand Up @@ -1210,7 +1217,9 @@ class PluginCLAP : ClapEventQueue
return true;
}

void flushParameters(const clap_input_events_t* const in, const clap_output_events_t* const out)
void flushParameters(const clap_input_events_t* const in,
const clap_output_events_t* const out,
const uint32_t frameOffset)
{
if (const uint32_t len = in != nullptr ? in->size(in) : 0)
{
Expand All @@ -1231,7 +1240,7 @@ class PluginCLAP : ClapEventQueue
if (out != nullptr)
{
clap_event_param_value_t clapEvent = {
{ sizeof(clap_event_param_value_t), 0, 0, CLAP_EVENT_PARAM_VALUE, CLAP_EVENT_IS_LIVE },
{ sizeof(clap_event_param_value_t), frameOffset, 0, CLAP_EVENT_PARAM_VALUE, CLAP_EVENT_IS_LIVE },
0, nullptr, 0, 0, 0, 0, 0.0
};

Expand Down Expand Up @@ -2336,7 +2345,7 @@ static CLAP_ABI bool clap_plugin_params_text_to_value(const clap_plugin_t* plugi
static CLAP_ABI void clap_plugin_params_flush(const clap_plugin_t* plugin, const clap_input_events_t* in, const clap_output_events_t* out)
{
PluginCLAP* const instance = static_cast<PluginCLAP*>(plugin->plugin_data);
return instance->flushParameters(in, out);
return instance->flushParameters(in, out, 0);
}

static const clap_plugin_params_t clap_plugin_params = {
Expand Down
12 changes: 7 additions & 5 deletions dpf/distrho/src/DistrhoPluginLV2export.cpp
Expand Up @@ -532,6 +532,9 @@ void lv2_generate_ttl(const char* const basename)
}
}

if ((port.hints & (kAudioPortIsCV|kCVPortIsOptional)) == (kAudioPortIsCV|kCVPortIsOptional))
pluginString += " lv2:portProperty lv2:connectionOptional;\n";

if (i+1 == DISTRHO_PLUGIN_NUM_INPUTS)
pluginString += " ] ;\n";
else
Expand Down Expand Up @@ -817,11 +820,10 @@ void lv2_generate_ttl(const char* const basename)
// MIDI CC binding
if (const uint8_t midiCC = plugin.getParameterMidiCC(i))
{
char midiCCBuf[7];
snprintf(midiCCBuf, sizeof(midiCCBuf), "B0%02x00", midiCC);
pluginString += " midi:binding \"";
pluginString += midiCCBuf;
pluginString += "\"^^midi:MidiEvent ;\n";
pluginString += " midi:binding [\n";
pluginString += " a midi:Controller ;\n";
pluginString += " midi:controllerNumber " + String(midiCC) + " ;\n";
pluginString += " ] ;\n";
}

// unit
Expand Down
47 changes: 23 additions & 24 deletions dpf/distrho/src/DistrhoPluginVST3.cpp
Expand Up @@ -14,36 +14,13 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "DistrhoPluginInternal.hpp"
#include "../DistrhoPluginUtils.hpp"
#include "../extra/ScopedPointer.hpp"

#define DPF_VST3_MAX_BUFFER_SIZE 32768
#define DPF_VST3_MAX_SAMPLE_RATE 384000
#define DPF_VST3_MAX_LATENCY DPF_VST3_MAX_SAMPLE_RATE * 10

#if DISTRHO_PLUGIN_HAS_UI
# include "../extra/RingBuffer.hpp"
#endif

#include "travesty/audio_processor.h"
#include "travesty/component.h"
#include "travesty/edit_controller.h"
#include "travesty/factory.h"
#include "travesty/host.h"

#include <map>
#include <string>
#include <vector>

/* TODO items:
* == parameters
* - test parameter triggers
* - have parameter outputs host-provided UI working in at least 1 host
* - parameter groups via unit ids
* - test parameter changes from DSP (aka requestParameterValueChange)
* - implement getParameterNormalized/setParameterNormalized for MIDI CC params ?
* - fully implemented parameter stuff and verify
* - float to int safe casting
* - verify that latency changes works (with and without DPF_VST3_USES_SEPARATE_CONTROLLER)
* == MIDI
Expand All @@ -60,6 +37,28 @@
* - do something with set_io_mode?
*/

#include "DistrhoPluginInternal.hpp"
#include "../DistrhoPluginUtils.hpp"
#include "../extra/ScopedPointer.hpp"

#define DPF_VST3_MAX_BUFFER_SIZE 32768
#define DPF_VST3_MAX_SAMPLE_RATE 384000
#define DPF_VST3_MAX_LATENCY DPF_VST3_MAX_SAMPLE_RATE * 10

#if DISTRHO_PLUGIN_HAS_UI
# include "../extra/RingBuffer.hpp"
#endif

#include "travesty/audio_processor.h"
#include "travesty/component.h"
#include "travesty/edit_controller.h"
#include "travesty/factory.h"
#include "travesty/host.h"

#include <map>
#include <string>
#include <vector>

START_NAMESPACE_DISTRHO

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2733,7 +2732,7 @@ class PluginVst3
}

if (busId < busInfo.groups)
return portCountToSpeaker(fPlugin.getAudioPortCountWithGroupId(isInput, busId));
return portCountToSpeaker(fPlugin.getAudioPortCountWithGroupId(isInput, portGroupId));

if (busInfo.audio != 0 && busId == busInfo.groups)
return portCountToSpeaker(busInfo.audioPorts);
Expand Down
2 changes: 1 addition & 1 deletion dpf/distrho/src/DistrhoUIDSSI.cpp
Expand Up @@ -27,7 +27,7 @@
START_NAMESPACE_DISTRHO

#if ! DISTRHO_PLUGIN_WANT_MIDI_INPUT
static const sendNoteFunc sendNoteCallback = nullptr;
static constexpr const sendNoteFunc sendNoteCallback = nullptr;
#endif

// -----------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions plugins/Nekobi/DistrhoPluginNekobi.cpp
Expand Up @@ -373,13 +373,12 @@ void DistrhoPluginNekobi::run(const float**, float** outputs, uint32_t frames, c
fSynth.nugget_remains = XSYNTH_NUGGET_SIZE;

/* process any ready events */
while (curEventIndex < midiEventCount && framesDone == midiEvents[curEventIndex].frame)
for (; curEventIndex < midiEventCount && framesDone == midiEvents[curEventIndex].frame; ++curEventIndex)
{
if (midiEvents[curEventIndex].size > MidiEvent::kDataSize)
continue;

nekobee_handle_raw_event(&fSynth, midiEvents[curEventIndex].size, midiEvents[curEventIndex].data);
curEventIndex++;
}

/* calculate the sample count (burstSize) for the next nekobee_voice_render() call to be the smallest of:
Expand Down
2 changes: 1 addition & 1 deletion plugins/Nekobi/nekobee-src/nekobee_voice_render.c
Expand Up @@ -376,7 +376,7 @@ nekobee_voice_render(nekobee_synth_t *synth, nekobee_voice_t *voice,

osc_index += sample_count;

if (do_control_update) {
if (do_control_update || osc_index > MINBLEP_BUFFER_LENGTH - (XSYNTH_NUGGET_SIZE + LONGEST_DD_PULSE_LENGTH)) {
/* do those things should be done only once per control-calculation
* interval ("nugget"), such as voice check-for-dead, pitch envelope
* calculations, volume envelope phase transition checks, etc. */
Expand Down
51 changes: 28 additions & 23 deletions plugins/ProM/ResizeHandle.hpp
Expand Up @@ -25,16 +25,6 @@ START_NAMESPACE_DGL
class ResizeHandle : public TopLevelWidget
{
public:
/** Constructor for placing this handle on top of a window. */
explicit ResizeHandle(Window& window)
: TopLevelWidget(window),
handleSize(16),
hasCursor(false),
isResizing(false)
{
resetArea();
}

/** Overloaded constructor, will fetch the window from an existing top-level widget. */
explicit ResizeHandle(TopLevelWidget* const tlw)
: TopLevelWidget(tlw->getWindow()),
Expand All @@ -56,31 +46,27 @@ class ResizeHandle : public TopLevelWidget
protected:
void onDisplay() override
{
// TODO implement gl3 stuff in DPF
#ifndef DGL_USE_OPENGL3
const GraphicsContext& context(getGraphicsContext());
const double lineWidth = 1.0 * getScaleFactor();

#if defined(DGL_OPENGL) && !defined(DGL_USE_OPENGL3)
glMatrixMode(GL_MODELVIEW);
#endif
glLineWidth(lineWidth);

// draw white lines, 1px wide
Color(1.0f, 1.0f, 1.0f).setFor(context);
l1.draw(context, lineWidth);
l2.draw(context, lineWidth);
l3.draw(context, lineWidth);
glColor3f(1.0f, 1.0f, 1.0f);
drawLine(l1);
drawLine(l2);
drawLine(l3);

// draw black lines, offset by 1px and 1px wide
Color(0.0f, 0.0f, 0.0f).setFor(context);
glColor3f(0.0f, 0.0f, 0.0f);
Line<double> l1b(l1), l2b(l2), l3b(l3);
l1b.moveBy(lineWidth, lineWidth);
l2b.moveBy(lineWidth, lineWidth);
l3b.moveBy(lineWidth, lineWidth);
l1b.draw(context, lineWidth);
l2b.draw(context, lineWidth);
l3b.draw(context, lineWidth);
#endif
drawLine(l1b);
drawLine(l2b);
drawLine(l3b);
}

bool onMouse(const MouseEvent& ev) override
Expand Down Expand Up @@ -201,6 +187,25 @@ class ResizeHandle : public TopLevelWidget
l3.setEndPos(x + offset, y + linesize + offset);
}

void drawLine(const Line<double>& line)
{
drawLine(line.getStartPos(), line.getEndPos());
}

void drawLine(const Point<double>& posStart, const Point<double>& posEnd)
{
DISTRHO_SAFE_ASSERT_RETURN(posStart != posEnd,);

glBegin(GL_LINES);

{
glVertex2d(posStart.getX(), posStart.getY());
glVertex2d(posEnd.getX(), posEnd.getY());
}

glEnd();
}

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ResizeHandle)
};

Expand Down