Skip to content

Commit

Permalink
implement fmop constructor and revert bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcBoule committed Oct 15, 2023
1 parent 368c0f3 commit a3c16ad
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"slug": "Geodesics",
"name": "Geodesics",
"version": "2.3.2",
"version": "2.3.1",
"license": "GPL-3.0-only",
"author": "Pyer & Marc Boul\u00e9",
"brand": "Geodesics",
Expand Down
10 changes: 6 additions & 4 deletions src/DarkEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ struct DarkEnergy : Module {
int panelTheme;

// Need to save, with reset
FMOp oscM[N_POLY];
FMOp oscC[N_POLY];
std::vector<FMOp> oscM;// size N_POLY
std::vector<FMOp> oscC;// size N_POLY
int plancks[2];// index is left/right, value is: 0 = not quantized, 1 = 5th+octs, 2 = adds -10V offset (LFO)
int mode;// main center modulation modes (bit 0 is fmDepth mode, bit 1 is feedback mode; a 0 bit means both sides CV modulated the same, a 1 bit means pos attenuverter mods right side only, neg atten means mod left side only (but still a positive attenuverter value though!))
int dest;// mult destination (bit 0 is fmDepth mode, bit 1 is feedback mode; a 0 bit means both sides CV modulated the same, a 1 bit means pos attenuverter mods right side only, neg atten means mod left side only (but still a positive attenuverter value though!))
Expand Down Expand Up @@ -144,9 +144,11 @@ struct DarkEnergy : Module {
configOutput(M_OUTPUT, "M");
configOutput(C_OUTPUT, "C");

oscM.reserve(N_POLY);
oscC.reserve(N_POLY);
for (int c = 0; c < N_POLY; c++) {
oscM[c].construct(APP->engine->getSampleRate());
oscC[c].construct(APP->engine->getSampleRate());
oscM.push_back(FMOp(APP->engine->getSampleRate()));
oscC.push_back(FMOp(APP->engine->getSampleRate()));
feedbacks[0][c] = 0.0f;
feedbacks[1][c] = 0.0f;
depths[0][c] = 0.0f;
Expand Down
10 changes: 6 additions & 4 deletions src/Energy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ struct Energy : Module {
int panelTheme;

// Need to save, with reset
FMOp oscM[N_POLY];
FMOp oscC[N_POLY];
std::vector<FMOp> oscM;// size N_POLY
std::vector<FMOp> oscC;// size N_POLY
int routing;// routing of knob 1.
// 0 is independant (i.e. blue only) (bottom light, light index 0),
// 1 is control (i.e. blue and yellow) (top light, light index 1),
Expand Down Expand Up @@ -101,9 +101,11 @@ struct Energy : Module {

configOutput(ENERGY_OUTPUT, "Energy");

oscM.reserve(N_POLY);
oscC.reserve(N_POLY);
for (int c = 0; c < N_POLY; c++) {
oscM[c].construct(APP->engine->getSampleRate());
oscC[c].construct(APP->engine->getSampleRate());
oscM.push_back(FMOp(APP->engine->getSampleRate()));
oscC.push_back(FMOp(APP->engine->getSampleRate()));
feedbacks[0][c] = 0.0f;
feedbacks[1][c] = 0.0f;
}
Expand Down
11 changes: 5 additions & 6 deletions src/EnergyOsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,12 @@ void FMOp::dataFromJson(json_t *rootJ, std::string id) {
_phasor.setPhase((Phasor::phase_t)json_integer_value(phaseJ));
}

void FMOp::onSampleRateChange(float newSampleRate) {
void FMOp::onSampleRateChange(const float newSampleRate) {
_steps = modulationSteps;
float sampleRate = newSampleRate;
_phasor.setSampleRate(sampleRate);
_decimator.setParams(sampleRate, oversample);
_maxFrequency = 0.475f * sampleRate;
_feedbackSL.setParams(sampleRate, 5.0f, 1.0f);
_phasor.setSampleRate(newSampleRate);
_decimator.setParams(newSampleRate, oversample);
_maxFrequency = 0.475f * newSampleRate;
_feedbackSL.setParams(newSampleRate, 5.0f, 1.0f);
}

float FMOp::step(float voct, float momentum, float fmDepth, float fmInput) {
Expand Down
6 changes: 3 additions & 3 deletions src/EnergyOsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,16 @@ struct FMOp {
int _steps = 0;
float _feedbackDelayedSample = 0.0f;
float _maxFrequency = 0.0f;
float _buffer[oversample];
float _buffer[oversample] = {};
float _oversampleMix = 0.0f;
Phasor _phasor;
SineTableOscillator _sineTable;
CICDecimator _decimator;
SlewLimiter _feedbackSL;

void construct(float _sampleRate) {
onReset();
FMOp(float _sampleRate) {
onSampleRateChange(_sampleRate);
onReset();
}

void onReset();
Expand Down

0 comments on commit a3c16ad

Please sign in to comment.