Skip to content

Commit

Permalink
cppcheck cleanup on PM and start MM
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcBoule committed Oct 9, 2023
1 parent 9565c2a commit 0d5270f
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 145 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 2.4.0 (in development)

- Fix code warnings using Cppcheck


### 2.2.3 (2023-04-11)

- Fix issue with Schmitt trigger
Expand Down
40 changes: 20 additions & 20 deletions src/MixMaster/AuxExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ struct AuxExpander : Module {
onReset();
}

void onReset() override {
void onReset() override final {
for (int i = 0; i < 4; i++) {
aux[i].onReset();
momentCvRetMuteLocal.cc4[i] = 1;
Expand Down Expand Up @@ -545,7 +545,7 @@ struct AuxExpander : Module {

motherPresent = (leftExpander.module && leftExpander.module->model == (N_TRK == 16 ? modelMixMaster : modelMixMasterJr));

AfmExpInterface *messagesFromMother = (AfmExpInterface*)leftExpander.consumerMessage;
AfmExpInterface *messagesFromMother = static_cast<AfmExpInterface*>(leftExpander.consumerMessage);

if (refresh.processInputs()) {
processMuteSoloCvTriggers();
Expand Down Expand Up @@ -704,7 +704,7 @@ struct AuxExpander : Module {
// To Mother
// ***********

MfaExpInterface *messagesToMother = (MfaExpInterface*)leftExpander.module->rightExpander.producerMessage;
MfaExpInterface *messagesToMother = static_cast<MfaExpInterface*>(leftExpander.module->rightExpander.producerMessage);

messagesToMother->updateSlow = refresh.refreshCounter == 0;
if (messagesToMother->updateSlow) {
Expand Down Expand Up @@ -791,15 +791,15 @@ struct AuxExpander : Module {


void writeTrackParams(int trk, float* bufDest) {
for (int aux = 0; aux < 4; aux++) {
bufDest[aux] = params[TRACK_AUXSEND_PARAMS + (trk << 2) + aux].getValue();
for (int i = 0; i < 4; i++) {
bufDest[i] = params[TRACK_AUXSEND_PARAMS + (trk << 2) + i].getValue();
}
bufDest[4] = params[TRACK_AUXMUTE_PARAMS + trk].getValue();
}

void readTrackParams(int trk, float* bufSrc) {
for (int aux = 0; aux < 4; aux++) {
params[TRACK_AUXSEND_PARAMS + (trk << 2) + aux].setValue(bufSrc[aux]);
for (int i = 0; i < 4; i++) {
params[TRACK_AUXSEND_PARAMS + (trk << 2) + i].setValue(bufSrc[i]);
}
params[TRACK_AUXMUTE_PARAMS + trk].setValue(bufSrc[4]);
}
Expand Down Expand Up @@ -881,32 +881,32 @@ struct AuxExpander : Module {
}
// return mutes and solos
if (inputs[POLY_BUS_MUTE_SOLO_CV_INPUT].isConnected()) {
for (int aux = 0; aux < 4; aux++) {
for (int i = 0; i < 4; i++) {
// mutes
state = muteSoloCvTriggers[aux + (N_TRK + N_GRP)].process(inputs[POLY_BUS_MUTE_SOLO_CV_INPUT].getVoltage(aux));
state = muteSoloCvTriggers[i + (N_TRK + N_GRP)].process(inputs[POLY_BUS_MUTE_SOLO_CV_INPUT].getVoltage(i));
if (state != 0) {
if (directOutPanStereoMomentCvLinearVol.cc4[2] >= 2 ? momentCvRetMuteLocal.cc4[aux] : directOutPanStereoMomentCvLinearVol.cc4[2]) {
if (directOutPanStereoMomentCvLinearVol.cc4[2] >= 2 ? momentCvRetMuteLocal.cc4[i] : directOutPanStereoMomentCvLinearVol.cc4[2]) {
if (state == 1) {
float newParam = 1.0f - params[GLOBAL_AUXMUTE_PARAMS + aux].getValue();// toggle
params[GLOBAL_AUXMUTE_PARAMS + aux].setValue(newParam);
float newParam = 1.0f - params[GLOBAL_AUXMUTE_PARAMS + i].getValue();// toggle
params[GLOBAL_AUXMUTE_PARAMS + i].setValue(newParam);
};
}
else {
params[GLOBAL_AUXMUTE_PARAMS + aux].setValue(state == 1 ? 1.0f : 0.0f);// gate level
params[GLOBAL_AUXMUTE_PARAMS + i].setValue(state == 1 ? 1.0f : 0.0f);// gate level
}
}

// solos
state = muteSoloCvTriggers[aux + (N_TRK + N_GRP) + 4].process(inputs[POLY_BUS_MUTE_SOLO_CV_INPUT].getVoltage(aux + 4));
state = muteSoloCvTriggers[i + (N_TRK + N_GRP) + 4].process(inputs[POLY_BUS_MUTE_SOLO_CV_INPUT].getVoltage(i + 4));
if (state != 0) {
if (directOutPanStereoMomentCvLinearVol.cc4[2] >= 2 ? momentCvRetSoloLocal.cc4[aux] : directOutPanStereoMomentCvLinearVol.cc4[2]) {
if (directOutPanStereoMomentCvLinearVol.cc4[2] >= 2 ? momentCvRetSoloLocal.cc4[i] : directOutPanStereoMomentCvLinearVol.cc4[2]) {
if (state == 1) {
float newParam = 1.0f - params[GLOBAL_AUXSOLO_PARAMS + aux].getValue();// toggle
params[GLOBAL_AUXSOLO_PARAMS + aux].setValue(newParam);
float newParam = 1.0f - params[GLOBAL_AUXSOLO_PARAMS + i].getValue();// toggle
params[GLOBAL_AUXSOLO_PARAMS + i].setValue(newParam);
};
}
else {
params[GLOBAL_AUXSOLO_PARAMS + aux].setValue(state == 1 ? 1.0f : 0.0f);// gate level
params[GLOBAL_AUXSOLO_PARAMS + i].setValue(state == 1 ? 1.0f : 0.0f);// gate level
}
}

Expand Down Expand Up @@ -980,7 +980,7 @@ struct AuxExpanderWidget : ModuleWidget {

// Main panels from Inkscape
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/dark/auxspander.svg")));
SvgPanel* svgPanel = (SvgPanel*)getPanel();
SvgPanel* svgPanel = static_cast<SvgPanel*>(getPanel());
panelBorder = findBorder(svgPanel->fb);


Expand Down Expand Up @@ -1368,7 +1368,7 @@ struct AuxExpanderJrWidget : ModuleWidget {

// Main panels from Inkscape
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/dark/auxspander-jr.svg")));
SvgPanel* svgPanel = (SvgPanel*)getPanel();
SvgPanel* svgPanel = static_cast<SvgPanel*>(getPanel());
panelBorder = findBorder(svgPanel->fb);


Expand Down
34 changes: 17 additions & 17 deletions src/MixMaster/AuxExpander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@ struct AuxspanderAux {

// need to save, with reset
private:
float hpfCutoffFreq;// always use getter and setter since tied to Biquad
float lpfCutoffFreq;// always use getter and setter since tied to Biquad
float hpfCutoffFreq = 0.0f;// always use getter and setter since tied to Biquad
float lpfCutoffFreq = 0.0f;// always use getter and setter since tied to Biquad
public:
float stereoWidth;// 0 to 1.0f; 0 is mono, 1 is stereo
float stereoWidth = 0.0f;// 0 to 1.0f; 0 is mono, 1 is stereo

// no need to save, with reset
bool stereo;
bool stereo = false;
private:
ButterworthThirdOrder hpFilter[2];// 18dB/oct
ButterworthSecondOrder lpFilter[2];// 12db/oct
float sampleTime;
float sampleTime = 0.0f;
SlewLimiterSingle stereoWidthSlewer;
public:

// no need to save, no reset
int auxNum;
char *auxLabel;
int auxNum = 0;
char *auxLabel = nullptr;
std::string ids;
Input *inSig;
int8_t *vuColorThemeLocal;
int8_t *directOutsModeLocal;
int8_t *panLawStereoLocal;
int8_t *dispColorAuxLocal;
float *panCvLevel;
float *auxFadeRatesAndProfile;
Param *trackAuxSendParam;// all spaced out by 4, N_TRK of them
Param *groupAuxSendParam;// all spaced out by 4, N_GRP of them
Param *globalAuxParam;// all spaced out by 4: mute, solo, group, send, pan, return
Input *inSig = nullptr;
int8_t *vuColorThemeLocal = nullptr;
int8_t *directOutsModeLocal = nullptr;
int8_t *panLawStereoLocal = nullptr;
int8_t *dispColorAuxLocal = nullptr;
float *panCvLevel = nullptr;
float *auxFadeRatesAndProfile = nullptr;
Param *trackAuxSendParam = nullptr;// all spaced out by 4, N_TRK of them
Param *groupAuxSendParam = nullptr;// all spaced out by 4, N_GRP of them
Param *globalAuxParam = nullptr;// all spaced out by 4: mute, solo, group, send, pan, return


void construct(int _auxNum, Input *_inputs, Param *_params, char* _auxLabel, int8_t *_vuColorThemeLocal, int8_t *_directOutsModeLocal, int8_t *_panLawStereoLocal, int8_t *_dispColorAuxLocal, float *_panCvLevel, float *_auxFadeRatesAndProfile) {
Expand Down
6 changes: 3 additions & 3 deletions src/MixMaster/AuxExpanderWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct AuxspanderInterchangeItem : MenuItem {


void appendContextMenu(Menu *menu) override {
TAuxExpander* module = (TAuxExpander*)(this->module);
TAuxExpander* module = static_cast<TAuxExpander*>(this->module);
assert(module);

AuxspanderInterchangeItem *interchangeItem = createMenuItem<AuxspanderInterchangeItem>("AuxSpander swap", RIGHT_ARROW);
Expand All @@ -67,7 +67,7 @@ void appendContextMenu(Menu *menu) override {

void step() override {
if (module) {
TAuxExpander* module = (TAuxExpander*)(this->module);
TAuxExpander* module = static_cast<TAuxExpander*>(this->module);

// Labels (pull from module)
if (module->updateAuxLabelRequest != 0) {// pull request from module
Expand All @@ -90,7 +90,7 @@ void step() override {
if (panelBorder->box.size.x != (box.size.x + newSizeAdd)) {
panelBorder->box.pos.x = -newSizeAdd;
panelBorder->box.size.x = (box.size.x + newSizeAdd);
SvgPanel* svgPanel = (SvgPanel*)getPanel();
SvgPanel* svgPanel = static_cast<SvgPanel*>(getPanel());
svgPanel->fb->dirty = true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/MixMaster/MixerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ float updateFadeGain(float fadeGain, float target, float *fadeGainX, float *fade
// fadeGainX moves from 0.0f to 1.0f gradually and linearly
// fadeGainXr is a resettable and relative gainX, which is used for non-symmetrical fades (to remember position when change direction while fade is happening
static const float A = 4.0f;
static const float E_A_M1 = (std::exp(A) - 1.0f);// e^A - 1
static const float E_A_M1 = std::expm1(A);// e^A - 1

float newFadeGain;

Expand All @@ -47,11 +47,11 @@ float updateFadeGain(float fadeGain, float target, float *fadeGainX, float *fade
newFadeGain = *fadeGainX;// linear
if (*fadeGainX != target) {
if (shape > 0.0f) {
float expY = (std::exp(A * *fadeGainX) - 1.0f)/E_A_M1;
float expY = std::expm1(A * *fadeGainX)/E_A_M1;
newFadeGain = crossfade(newFadeGain, expY, shape);
}
else if (shape < 0.0f) {
float logY = std::log(*fadeGainX * E_A_M1 + 1.0f) / A;
float logY = std::log1p(*fadeGainX * E_A_M1) / A;
newFadeGain = crossfade(newFadeGain, logY, -1.0f * shape);
}
}
Expand All @@ -64,7 +64,7 @@ float updateFadeGain(float fadeGain, float target, float *fadeGainX, float *fade
fadeGainDelta = crossfade(fadeGainDelta, fadeGainDeltaExp, shape);
}
else if (shape < 0.0f) {
float fadeGainDeltaLog = (std::log((*fadeGainXr) * E_A_M1 + 1.0f) - std::log((*fadeGainXr - timeStepX) * E_A_M1 + 1.0f)) / A;
float fadeGainDeltaLog = (std::log1p((*fadeGainXr) * E_A_M1) - std::log1p((*fadeGainXr - timeStepX) * E_A_M1)) / A;
fadeGainDelta = crossfade(fadeGainDelta, fadeGainDeltaLog, -1.0f * shape);
}

Expand Down
2 changes: 1 addition & 1 deletion src/MixMaster/MixerCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ struct TrackSettingsCpBuffer {
};


static inline bool isLinked(unsigned long *linkBitMaskSrc, int index) {return (*linkBitMaskSrc & (1 << index)) != 0;}
static inline bool isLinked(const unsigned long *linkBitMaskSrc, int index) {return (*linkBitMaskSrc & (1 << index)) != 0;}
static inline void toggleLinked(unsigned long *linkBitMaskSrc, int index) {*linkBitMaskSrc ^= (1 << index);}


Expand Down
Loading

0 comments on commit 0d5270f

Please sign in to comment.