Continue work on jucewrapper
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
6251756f4b
commit
649c88629e
3 changed files with 226 additions and 26 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
|
|
@ -17,15 +17,14 @@
|
|||
|
||||
#include <juce_audio_processors/juce_audio_processors.h>
|
||||
|
||||
#include "DistrhoPlugin.hpp"
|
||||
#include "DistrhoUI.hpp"
|
||||
|
||||
DISTRHO_PLUGIN_EXPORT DISTRHO_NAMESPACE::Plugin* createSharedPlugin();
|
||||
#define createPlugin ::createSharedPlugin
|
||||
#define createPlugin createStaticPlugin
|
||||
#include "src/DistrhoPluginInternal.hpp"
|
||||
#include "src/DistrhoUIInternal.hpp"
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
#if 0
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
class ParameterForDPF : public juce::AudioProcessorParameter
|
||||
|
|
@ -69,29 +68,43 @@ protected:
|
|||
return 0.0f;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
class CardinalWrapperProcessor : public juce::AudioProcessor
|
||||
{
|
||||
friend class CardinalWrapperEditor;
|
||||
|
||||
PluginExporter plugin;
|
||||
|
||||
static bool writeMidiCb(void* ptr, const MidiEvent& midiEvent)
|
||||
static bool writeMidi(void* ptr, const MidiEvent& midiEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool requestParameterValueChangeCb(void* ptr, uint32_t index, float value)
|
||||
static bool requestParameterValueChange(void* ptr, uint32_t index, float value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool updateStateValue(void* ptr, const char* key, const char* value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
CardinalWrapperProcessor()
|
||||
: plugin(this, writeMidiCb, requestParameterValueChangeCb)
|
||||
: plugin(this, writeMidi, requestParameterValueChange, updateStateValue)
|
||||
{
|
||||
for (uint i=0; i<plugin.getParameterCount(); ++i)
|
||||
addParameter(new ParameterForDPF(plugin, i));
|
||||
if (const double sampleRate = getSampleRate())
|
||||
plugin.setSampleRate(sampleRate);
|
||||
|
||||
if (const int blockSize = getBlockSize())
|
||||
plugin.setBufferSize(blockSize);
|
||||
|
||||
// for (uint i=0; i<plugin.getParameterCount(); ++i)
|
||||
// addParameter(new ParameterForDPF(plugin, i));
|
||||
}
|
||||
|
||||
~CardinalWrapperProcessor() override
|
||||
|
|
@ -125,11 +138,25 @@ public:
|
|||
{
|
||||
midiMessages.clear();
|
||||
// AudioPlayHead* getPlayHead()
|
||||
|
||||
const int numSamples = buffer.getNumSamples();
|
||||
DISTRHO_SAFE_ASSERT_INT_RETURN(numSamples > 0, numSamples,);
|
||||
|
||||
DISTRHO_SAFE_ASSERT_RETURN(buffer.getNumChannels() == 2,);
|
||||
|
||||
const float* audioBufferIn[2];
|
||||
float* audioBufferOut[2];
|
||||
audioBufferIn[0] = buffer.getReadPointer(0);
|
||||
audioBufferIn[1] = buffer.getReadPointer(1);
|
||||
audioBufferOut[0] = buffer.getWritePointer(0);
|
||||
audioBufferOut[1] = buffer.getWritePointer(1);
|
||||
|
||||
plugin.run(audioBufferIn, audioBufferOut, numSamples, nullptr, 0);
|
||||
}
|
||||
|
||||
double getTailLengthSeconds() const override
|
||||
{
|
||||
return true;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool acceptsMidi() const override
|
||||
|
|
@ -181,17 +208,80 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
class CardinalWrapperEditor : public juce::AudioProcessorEditor
|
||||
{
|
||||
UIExporter* ui;
|
||||
void* const dspPtr;
|
||||
|
||||
static void editParamFunc(void* ptr, uint32_t rindex, bool started) {}
|
||||
static void setParamFunc(void* ptr, uint32_t rindex, float value) {}
|
||||
static void setStateFunc(void* ptr, const char* key, const char* value) {}
|
||||
static void sendNoteFunc(void* ptr, uint8_t channel, uint8_t note, uint8_t velo) {}
|
||||
|
||||
static void setSizeFunc(void* ptr, uint width, uint height)
|
||||
{
|
||||
static_cast<CardinalWrapperEditor*>(ptr)->setSize(width, height);
|
||||
}
|
||||
|
||||
static bool fileRequestFunc(void* ptr, const char* key) { return false; }
|
||||
|
||||
public:
|
||||
CardinalWrapperEditor(CardinalWrapperProcessor& processor)
|
||||
: juce::AudioProcessorEditor(processor)
|
||||
{}
|
||||
CardinalWrapperEditor(CardinalWrapperProcessor& cardinalProcessor)
|
||||
: juce::AudioProcessorEditor(cardinalProcessor),
|
||||
ui(nullptr),
|
||||
dspPtr(cardinalProcessor.plugin.getInstancePointer())
|
||||
{
|
||||
setOpaque(true);
|
||||
setResizable(true, false);
|
||||
// setResizeLimits(648, 538, -1, -1);
|
||||
setSize(1228, 666);
|
||||
}
|
||||
|
||||
~CardinalWrapperEditor() override
|
||||
{}
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void paint(juce::Graphics&)
|
||||
{
|
||||
if (ui == nullptr)
|
||||
{
|
||||
auto peer = getPeer();
|
||||
d_stdout("peer is %p", peer);
|
||||
|
||||
auto handle = peer->getNativeHandle();
|
||||
d_stdout("handle is %p", handle);
|
||||
|
||||
auto proc = getAudioProcessor();
|
||||
d_stdout("proc is %p", proc);
|
||||
|
||||
ui = new UIExporter(this,
|
||||
(uintptr_t)handle,
|
||||
proc->getSampleRate(),
|
||||
editParamFunc,
|
||||
setParamFunc,
|
||||
setStateFunc,
|
||||
sendNoteFunc,
|
||||
setSizeFunc,
|
||||
fileRequestFunc,
|
||||
nullptr, // bundlePath
|
||||
dspPtr,
|
||||
0.0 // scaleFactor
|
||||
);
|
||||
}
|
||||
|
||||
ui->plugin_idle();
|
||||
repaint();
|
||||
}
|
||||
};
|
||||
|
||||
juce::AudioProcessorEditor* CardinalWrapperProcessor::createEditor()
|
||||
{
|
||||
return new CardinalWrapperEditor(*this);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
END_NAMESPACE_DISTRHO
|
||||
|
|
@ -200,11 +290,10 @@ END_NAMESPACE_DISTRHO
|
|||
|
||||
juce::AudioProcessor* createPluginFilter()
|
||||
{
|
||||
// set valid but dummy values
|
||||
d_nextBufferSize = 512;
|
||||
d_nextSampleRate = 48000.0;
|
||||
return new DISTRHO_NAMESPACE::CardinalWrapperProcessor;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define DISTRHO_IS_STANDALONE 0
|
||||
#include "src/DistrhoPlugin.cpp"
|
||||
#include "src/DistrhoUtils.cpp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue