Skip to content

Commit 5e8ad47

Browse files
committed
stop requiring lv2 instance-access
1 parent cf78c40 commit 5e8ad47

File tree

8 files changed

+96
-44
lines changed

8 files changed

+96
-44
lines changed

plugins/string-machine-chorus-stereo/meta/DistrhoPluginInfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#define DISTRHO_PLUGIN_WANT_FULL_STATE 0
2323
#define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:ChorusPlugin"
2424

25-
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1
26-
2725
enum {
2826
pIdBypass,
2927

plugins/string-machine-chorus/meta/DistrhoPluginInfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#define DISTRHO_PLUGIN_WANT_FULL_STATE 0
2323
#define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:ChorusPlugin"
2424

25-
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1
26-
2725
enum {
2826
pIdBypass,
2927

plugins/string-machine/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ BUILD_CXX_FLAGS += \
6565
# --------------------------------------------------------------
6666
# Enable all possible plugin types
6767

68-
TARGETS += lv2
68+
TARGETS += lv2_sep
6969
TARGETS += vst
7070

7171
all: $(TARGETS)

plugins/string-machine/StringMachinePlugin.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ float StringMachinePlugin::getParameterValue(uint32_t index) const
116116
case pIdMasterGain:
117117
return synth.getMasterGain();
118118

119+
case pIdOutDetuneUpper:
120+
return fSynth.getLastDetuneUpper();
121+
case pIdOutDetuneLower:
122+
return fSynth.getLastDetuneLower();
123+
case pIdOutChorusPhase1:
124+
return (2 * M_PI) * fSynth.getChorus().getPhase1();
125+
case pIdOutChorusPhase2:
126+
return (2 * M_PI) * fSynth.getChorus().getPhase2();
127+
case pIdOutMasterLevel1:
128+
case pIdOutMasterLevel2:
129+
{
130+
double level = fOutputLevelFollower[index - pIdOutMasterLevel1].last_output();
131+
return 20 * std::log10(std::max(level, 1e-5));
132+
}
133+
119134
default:
120135
DISTRHO_SAFE_ASSERT(false);
121136
return 0.0;
@@ -205,6 +220,14 @@ void StringMachinePlugin::setParameterValue(uint32_t index, float value)
205220
synth.setMasterGain(value);
206221
break;
207222

223+
case pIdOutDetuneUpper:
224+
case pIdOutDetuneLower:
225+
case pIdOutChorusPhase1:
226+
case pIdOutChorusPhase2:
227+
case pIdOutMasterLevel1:
228+
case pIdOutMasterLevel2:
229+
break;
230+
208231
default:
209232
DISTRHO_SAFE_ASSERT(false);
210233
break;

plugins/string-machine/StringMachinePlugin.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ class StringMachinePlugin : public Plugin {
2929
void run(const float **inputs, float **outputs, uint32_t frames,
3030
const MidiEvent *midiEvents, uint32_t midiEventCount) override;
3131

32-
//
33-
float getLastDetuneUpper() const { return fSynth.getLastDetuneUpper(); }
34-
float getLastDetuneLower() const { return fSynth.getLastDetuneLower(); }
35-
36-
float getChorusPhase1() const { return fSynth.getChorus().getPhase1(); }
37-
float getChorusPhase2() const { return fSynth.getChorus().getPhase2(); }
38-
39-
double getLeftOutputLevel() const { return fOutputLevelFollower[0].last_output(); }
40-
double getRightOutputLevel() const { return fOutputLevelFollower[1].last_output(); }
41-
4232
private:
4333
StringSynth fSynth;
4434
AmpFollower fOutputLevelFollower[2];

plugins/string-machine/StringMachineShared.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "StringMachineShared.hpp"
2+
#include <cmath>
23

34
void InitParameter(uint32_t index, Parameter &parameter)
45
{
@@ -171,6 +172,47 @@ void InitParameter(uint32_t index, Parameter &parameter)
171172
parameter.ranges = ParameterRanges(3.0, -60.0, +20.0);
172173
break;
173174

175+
case pIdOutDetuneUpper:
176+
parameter.symbol = "osc_current_detune_upper";
177+
parameter.name = "Oscillator detune 4'";
178+
parameter.hints = kParameterIsAutomable|kParameterIsOutput;
179+
parameter.ranges = ParameterRanges(0.0, -1.0, +1.0);
180+
break;
181+
case pIdOutDetuneLower:
182+
parameter.symbol = "osc_current_detune_lower";
183+
parameter.name = "Oscillator detune 8'";
184+
parameter.hints = kParameterIsAutomable|kParameterIsOutput;
185+
parameter.ranges = ParameterRanges(0.0, -1.0, +1.0);
186+
break;
187+
case pIdOutChorusPhase1:
188+
parameter.symbol = "cho_current_phase1";
189+
parameter.name = "Chorus phase 1";
190+
parameter.hints = kParameterIsAutomable|kParameterIsOutput;
191+
parameter.unit = "rad";
192+
parameter.ranges = ParameterRanges(0.0, 0.0, 2 * M_PI);
193+
break;
194+
case pIdOutChorusPhase2:
195+
parameter.symbol = "cho_current_phase2";
196+
parameter.name = "Chorus phase 2";
197+
parameter.hints = kParameterIsAutomable|kParameterIsOutput;
198+
parameter.unit = "rad";
199+
parameter.ranges = ParameterRanges(0.0, 0.0, 2 * M_PI);
200+
break;
201+
case pIdOutMasterLevel1:
202+
parameter.symbol = "master_current_level1";
203+
parameter.name = "Master level 1";
204+
parameter.hints = kParameterIsAutomable|kParameterIsOutput;
205+
parameter.unit = "dB";
206+
parameter.ranges = ParameterRanges(0.0, -100.0, +100.0);
207+
break;
208+
case pIdOutMasterLevel2:
209+
parameter.symbol = "master_current_level2";
210+
parameter.name = "Master level 2";
211+
parameter.hints = kParameterIsAutomable|kParameterIsOutput;
212+
parameter.unit = "dB";
213+
parameter.ranges = ParameterRanges(0.0, -100.0, +100.0);
214+
break;
215+
174216
default:
175217
DISTRHO_SAFE_ASSERT(false);
176218
break;

plugins/string-machine/StringMachineUI.cpp

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "StringMachineUI.hpp"
22
#include "StringMachineUILayouts.hpp"
3-
#include "StringMachinePlugin.hpp"
43
#include "StringMachinePresets.hpp"
54
#include "Artwork.hpp"
65
#include "Window.hpp"
@@ -316,32 +315,6 @@ void StringMachineUI::programLoaded(uint32_t index)
316315

317316
void StringMachineUI::uiIdle()
318317
{
319-
StringMachinePlugin *plugin = (StringMachinePlugin *)getPluginInstancePointer();
320-
321-
fLfoIndicator[0]->setValue(plugin->getChorusPhase1() > 0.5f);
322-
fLfoIndicator[1]->setValue(plugin->getChorusPhase2() > 0.5f);
323-
324-
fOscDetuneDisplay[0]->setText(formatDisplayValue(std::fabs(plugin->getLastDetuneUpper())));
325-
fOscDetuneDisplay[1]->setText(formatDisplayValue(std::fabs(plugin->getLastDetuneLower())));
326-
327-
double leftLevel = plugin->getLeftOutputLevel();
328-
double rightLevel = plugin->getRightOutputLevel();
329-
330-
for (unsigned i = 0; i < 2; ++i) {
331-
constexpr double levelMin = -20.0;
332-
333-
double levelLin = 0.0;
334-
double levelLog = 0.0;
335-
336-
switch (i) {
337-
case 0: levelLin = leftLevel; break;
338-
case 1: levelLin = rightLevel; break;
339-
}
340-
341-
if (levelLin > 0.0)
342-
levelLog = (20.0 * std::log10(levelLin) - levelMin) * (1.0 / (- levelMin));
343-
fVuDisplay[i]->setValue(levelLog);
344-
}
345318
}
346319

347320
bool StringMachineUI::onKeyboard(const KeyboardEvent &event)
@@ -395,6 +368,28 @@ void StringMachineUI::updateParameterValue(uint32_t index, float value)
395368
fEnvSettings.release = value;
396369
fAdsrView->invalidateData();
397370
break;
371+
372+
case pIdOutDetuneUpper:
373+
fOscDetuneDisplay[0]->setText(formatDisplayValue(std::fabs(value)));
374+
break;
375+
case pIdOutDetuneLower:
376+
fOscDetuneDisplay[1]->setText(formatDisplayValue(std::fabs(value)));
377+
break;
378+
case pIdOutChorusPhase1:
379+
case pIdOutChorusPhase2:
380+
{
381+
SkinIndicator &x = *fLfoIndicator[index - pIdOutChorusPhase1];
382+
x.setValue(value > M_PI);
383+
break;
384+
}
385+
case pIdOutMasterLevel1:
386+
case pIdOutMasterLevel2:
387+
{
388+
SkinIndicator &x = *fVuDisplay[index - pIdOutMasterLevel1];
389+
constexpr double levelMin = -20.0, levelMax = 0.0;
390+
x.setValue((value - levelMin) * (1.0 / (levelMax - levelMin)));
391+
break;
392+
}
398393
}
399394
}
400395

plugins/string-machine/meta/DistrhoPluginInfo.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#define DISTRHO_PLUGIN_WANT_STATE 0
2222
#define DISTRHO_PLUGIN_WANT_FULL_STATE 0
2323

24-
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1
25-
2624
enum {
2725
pIdOscDetune,
2826
pIdOscHpCutoffUpper,
@@ -54,6 +52,14 @@ enum {
5452

5553
pIdMasterGain,
5654

55+
///
56+
pIdOutDetuneUpper,
57+
pIdOutDetuneLower,
58+
pIdOutChorusPhase1,
59+
pIdOutChorusPhase2,
60+
pIdOutMasterLevel1,
61+
pIdOutMasterLevel2,
62+
5763
///
5864
Parameter_Count
5965
};

0 commit comments

Comments
 (0)