Skip to content

Commit

Permalink
add some presets
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcima committed Jul 11, 2019
1 parent 1683d26 commit a7cdae0
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 41 deletions.
41 changes: 39 additions & 2 deletions plugins/string-machine/DistrhoPluginInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,46 @@
#define DISTRHO_PLUGIN_HAS_EMBED_UI 1
#define DISTRHO_PLUGIN_HAS_EXTERNAL_UI 0
#define DISTRHO_PLUGIN_IS_RT_SAFE 1
#define DISTRHO_PLUGIN_WANT_PROGRAMS 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
#define DISTRHO_PLUGIN_WANT_STATE 0
#define DISTRHO_PLUGIN_WANT_FULL_STATE 0
#define DISTRHO_PLUGIN_NUM_PROGRAMS 0

#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1

enum {
pIdOscDetune,
pIdOscHpCutoffUpper,
pIdOscHpCutoffLower,

pIdFltLpCutoffUpper,
pIdFltHpCutoffUpper,
pIdFltLpCutoffLower,
pIdFltHpCutoffLower,
pIdFltHsCutoffEq,
pIdFltHsBoostEq,

pIdMixGainUpper,
pIdMixGainLower,

pIdEnvAttack,
pIdEnvDecay,
pIdEnvSustain,
pIdEnvRelease,

pIdChoEnabled,
pIdChoDepth,
pIdChoRate1,
pIdChoDepth1,
pIdChoRate2,
pIdChoDepth2,

pIdMasterGain,

///
Parameter_Count
};

enum {
///
State_Count,
};
18 changes: 17 additions & 1 deletion plugins/string-machine/StringMachinePlugin.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "StringMachinePlugin.hpp"
#include "StringMachinePresets.hpp"
#include "StringSynthDefs.h"
#include "DenormalDisabler.h"

StringMachinePlugin::StringMachinePlugin()
: Plugin(Parameter_Count, DISTRHO_PLUGIN_NUM_PROGRAMS, State_Count)
: Plugin(Parameter_Count, NumPrograms, State_Count)
{
double sampleRate = getSampleRate();

Expand Down Expand Up @@ -207,6 +208,21 @@ void StringMachinePlugin::setParameterValue(uint32_t index, float value)
}
}

void StringMachinePlugin::initProgramName(uint32_t index, String &programName)
{
DISTRHO_SAFE_ASSERT_RETURN(index < NumPrograms, );

programName = "Program " + String(index + 1);
}

void StringMachinePlugin::loadProgram(uint32_t index)
{
DISTRHO_SAFE_ASSERT_RETURN(index < NumPrograms, );

for (unsigned p = 0; p < Parameter_Count; ++p)
setParameterValue(p, Programs[index][p]);
}

void StringMachinePlugin::run(const float **, float **outputs, uint32_t totalFrames,
const MidiEvent *midiEvents, uint32_t midiEventCount)
{
Expand Down
3 changes: 3 additions & 0 deletions plugins/string-machine/StringMachinePlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class StringMachinePlugin : public Plugin {
float getParameterValue(uint32_t index) const override;
void setParameterValue(uint32_t index, float value) override;

void initProgramName(uint32_t index, String &programName);
void loadProgram(uint32_t index);

void run(const float **inputs, float **outputs, uint32_t frames,
const MidiEvent *midiEvents, uint32_t midiEventCount) override;

Expand Down
27 changes: 27 additions & 0 deletions plugins/string-machine/StringMachinePresets.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once
#include "DistrhoPluginInfo.h"

#if !defined(DECL_IGNORABLE)
#if defined(__GNUC__)
#define DECL_IGNORABLE __attribute__((unused))
#else
#define DECL_IGNORABLE
#endif
#endif

DECL_IGNORABLE static float Programs[][Parameter_Count] = {
{ 0.001600, 8.000000, 8.000000, 5.200000, 12.200000, 16.400000, -0.400000, 24.799999, 6.000000, 0.000000, 0.000000, 0.193900, 10.000000, 0.000000, 3.000000, 1.000000, 1.000000, 5.834600, 0.307100, 0.583500, 0.905500, 3.000000, },
{ 0.027129, 13.751908, 3.550329, 111.940819, 113.698227, 3.230055, 82.139847, 52.353306, -5.268259, -2.033016, -3.028452, 4.115991, 7.773351, -29.139240, 2.758555, 1.000000, 0.780778, 6.670492, 0.139527, 0.740738, 0.618650, 12.60000, },
{ 0.043244, 4.417531, 13.443770, 92.953781, 35.042316, 67.681725, 69.532272, 4.708627, 5.136643, -6.126668, -6.568069, 0.030132, 2.951330, -31.476854, 1.425957, 1.000000, 0.478171, 4.960168, 0.373651, 0.565295, 0.362908, 9.400000, },
{ 0.061616, 6.338297, 0.259514, 116.376091, 87.940025, 22.876650, 51.090611, 115.211327, 11.893587, -2.143300, -17.412321, 3.619872, 7.896935, -27.755318, 6.130506, 1.000000, 0.871913, 5.747424, 0.868623, 0.310636, 0.807798, 4.600000, },
{ 0.042498, 16.680204, 15.141696, 74.672966, 22.302313, 13.043892, 18.159254, 16.107967, 6.970053, -12.131934, -4.881592, 1.052701, 5.903785, -1.617218, 2.134185, 0.000000, 0.155884, 3.132591, 0.838435, 0.587004, 0.813793, 11.00000, },
{ 0.015428, 0.469910, 18.814665, -12.824000, 61.583183, -17.186228, 106.693146, 89.783455, -2.160404, -0.042468, -1.470323, 9.855900, 1.745053, -16.969635, 5.553646, 1.000000, 0.536837, 3.643120, 0.525472, 0.671323, 0.687615, 12.60000, },
{ 0.028021, 9.607654, 16.005123, 50.868580, 66.392921, 91.836090, 86.784729, 72.863167, -16.532845, -15.381107, -2.654770, 0.748022, 4.693394, -29.766455, 4.258525, 1.000000, 0.669624, 6.418504, 0.357346, 0.346988, 0.357405, 12.60000, },
{ 0.015421, 10.124370, 4.642849, 31.348833, 93.655632, 103.735344, 35.569157, 104.340355, 16.077915, -9.120691, -0.399578, 2.514343, 8.863074, -17.196754, 1.585154, 1.000000, 0.949236, 3.057504, 0.841852, 0.389675, 0.900703, 4.600000, },
{ 0.025778, 6.603483, 9.939932, 40.520622, 72.934181, -16.914650, 33.332161, 9.397524, -7.853272, -12.375651, -15.463691, 1.411661, 7.472600, -20.249472, 8.633201, 1.000000, 0.553316, 3.856230, 0.921006, 0.369750, 0.939046, 17.40000, },
{ 0.041039, 1.782128, 3.749014, 76.500214, 112.430672, 84.163147, -7.156106, 20.835140, 3.226208, -16.107695, -6.126067, 1.521947, 1.508980, -13.988508, 9.927961, 1.000000, 0.329778, 3.613224, 0.235064, 0.857304, 0.170591, 11.80000, },
{ 0.011156, 1.333257, 14.318451, 8.265411, 99.357086, 4.534880, 14.566812, 94.055496, 14.924463, -1.453580, -9.598715, 5.995292, 6.723666, -32.200966, 8.461777, 1.000000, 0.271058, 5.494833, 0.012325, 0.460241, 0.411218, 4.600000, },
{ 0.050069, 19.217703, 4.409960, 105.867607, 117.830040, -0.604630, 54.132389, 11.490669, 7.113006, -7.439813, -7.781140, 0.158582, 6.742130, -31.624033, 6.370217, 1.000000, 0.100000, 9.000000, 0.010000, 0.359709, 0.077917, 12.600000, },
};

DECL_IGNORABLE static constexpr unsigned NumPrograms = sizeof(Programs) / sizeof(Programs[0]);
38 changes: 0 additions & 38 deletions plugins/string-machine/StringMachineShared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,3 @@
#include <cstdint>

void InitParameter(uint32_t index, Parameter &parameter);

enum {
pIdOscDetune,
pIdOscHpCutoffUpper,
pIdOscHpCutoffLower,

pIdFltLpCutoffUpper,
pIdFltHpCutoffUpper,
pIdFltLpCutoffLower,
pIdFltHpCutoffLower,
pIdFltHsCutoffEq,
pIdFltHsBoostEq,

pIdMixGainUpper,
pIdMixGainLower,

pIdEnvAttack,
pIdEnvDecay,
pIdEnvSustain,
pIdEnvRelease,

pIdChoEnabled,
pIdChoDepth,
pIdChoRate1,
pIdChoDepth1,
pIdChoRate2,
pIdChoDepth2,

pIdMasterGain,

///
Parameter_Count
};

enum {
///
State_Count,
};
9 changes: 9 additions & 0 deletions plugins/string-machine/StringMachineUI.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "StringMachineUI.hpp"
#include "StringMachineUILayouts.hpp"
#include "StringMachinePlugin.hpp"
#include "StringMachinePresets.hpp"
#include "Artwork.hpp"
#include "Window.hpp"
#include "ui/components/SkinSlider.hpp"
Expand Down Expand Up @@ -295,6 +296,14 @@ void StringMachineUI::parameterChanged(uint32_t index, float value)
updateParameterValue(index, value);
}

void StringMachineUI::programLoaded(uint32_t index)
{
DISTRHO_SAFE_ASSERT_RETURN(index < NumPrograms, );

for (unsigned p = 0; p < Parameter_Count; ++p)
parameterChanged(index, Programs[index][p]);
}

void StringMachineUI::uiIdle()
{
StringMachinePlugin *plugin = (StringMachinePlugin *)getPluginInstancePointer();
Expand Down
1 change: 1 addition & 0 deletions plugins/string-machine/StringMachineUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class StringMachineUI : public UI {
protected:
void onDisplay() override;
void parameterChanged(uint32_t index, float value) override;
void programLoaded(uint32_t index) override;
void uiIdle() override;

bool onKeyboard(const KeyboardEvent &event) override;
Expand Down

0 comments on commit a7cdae0

Please sign in to comment.