Skip to content

Commit

Permalink
more cppcheck refactor and warning cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcBoule committed Oct 15, 2023
1 parent 43a064f commit 752fdbe
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
23 changes: 12 additions & 11 deletions src/MixMaster/MixMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct MixMaster : Module {
GlobalInfo gInfo;
MixerTrack tracks[N_TRK];
MixerGroup groups[N_GRP];
MixerAux aux[4];
std::vector<MixerAux> aux;// size 4
MixerMaster master;

// No need to save, with reset
Expand Down Expand Up @@ -238,8 +238,9 @@ struct MixMaster : Module {
for (int i = 0; i < N_GRP; i++) {
groups[i].construct(i, &gInfo, &inputs[0], &params[0], &(trackLabels[4 * (N_TRK + i)]), &groupTaps[i << 1], &groupInsertOuts[i << 1]);
}
aux.reserve(4);
for (int i = 0; i < 4; i++) {
aux[i].construct(i, &gInfo, &inputs[0], values20, &auxTaps[i << 1], &stereoPanModeLocalAux.cc4[i]);
aux.push_back(MixerAux(i, &gInfo, &inputs[0], values20, &auxTaps[i << 1], &stereoPanModeLocalAux.cc4[i]));
}
master.construct(&gInfo, &params[0], &inputs[0]);
muteTrackWhenSoloAuxRetSlewer.setRiseFall(GlobalConst::antipopSlewFast); // slew rate is in input-units per second
Expand All @@ -260,7 +261,7 @@ struct MixMaster : Module {
}


void onReset() override {
void onReset() override final {
gInfo.onReset();
for (int i = 0; i < N_TRK; i++) {
tracks[i].onReset();
Expand Down Expand Up @@ -528,7 +529,7 @@ struct MixMaster : Module {

// From Aux-Expander
if (auxExpanderPresent) {
MfaExpInterface *messagesFromExpander = (MfaExpInterface*)rightExpander.consumerMessage;// could be invalid pointer when !expanderPresent, so read it only when expanderPresent
MfaExpInterface *messagesFromExpander = static_cast<MfaExpInterface*>(rightExpander.consumerMessage);// could be invalid pointer when !expanderPresent, so read it only when expanderPresent

// Slow values from expander
if (messagesFromExpander->updateSlow) {
Expand Down Expand Up @@ -672,7 +673,7 @@ struct MixMaster : Module {

// To Aux-Expander
if (auxExpanderPresent) {
AfmExpInterface *messageToExpander = (AfmExpInterface*)(rightExpander.module->leftExpander.producerMessage);
AfmExpInterface *messageToExpander = static_cast<AfmExpInterface*>(rightExpander.module->leftExpander.producerMessage);

// Slow
messageToExpander->updateSlow = refresh.refreshCounter == 0;
Expand Down Expand Up @@ -762,12 +763,12 @@ struct MixMaster : Module {
memcpy(auxSends, &trackTaps[gInfo.auxSendsMode << (3 + N_TRK / 8)], (N_TRK * 2) * 4);
}
else {
int trkGroup;
for (int trk = 0; trk < N_TRK; trk++) {
// tracks should have aux sends even when grouped
int tapIndex = (tracks[trk].auxSendsMode << (3 + N_TRK / 8));
float trackL = trackTaps[tapIndex + (trk << 1) + 0];
float trackR = trackTaps[tapIndex + (trk << 1) + 1];
int trkGroup;
if (gInfo.groupsControlTrackSendLevels != 0 && (trkGroup = (int)(tracks[trk].paGroup->getValue() + 0.5f)) != 0) {
trkGroup--;
simd::float_4 sigs(trackL, trackR, trackR, trackL);
Expand Down Expand Up @@ -862,15 +863,15 @@ struct MixMaster : Module {
}

// Aux
// this uses one of the taps in the aux return signal flow (same signal flow as a group), and choice of tap is same as other diretct outs
// this uses one of the taps in the aux return signal flow (same signal flow as a group), and choice of tap is same as other direct outs
if (auxExpanderPresent) {
if (gInfo.directOutPanStereoMomentCvLinearVol.cc4[0] < 4) {// global direct outs
int tapIndex = gInfo.directOutPanStereoMomentCvLinearVol.cc4[0];
tapIndex = gInfo.directOutPanStereoMomentCvLinearVol.cc4[0];
memcpy(outputs[outputNum].getVoltages(8), &auxTaps[(tapIndex << 3)], 4 * 8);
}
else {// per aux direct outs
for (unsigned int i = 0; i < 4; i++) {
int tapIndex = directOutsModeLocalAux.cc4[i];
tapIndex = directOutsModeLocalAux.cc4[i];
int offset = (tapIndex << 3) + (i << 1);
outputs[outputNum].setVoltage(auxTaps[offset + 0], 8 + 2 * i);
outputs[outputNum].setVoltage(auxTaps[offset + 1], 8 + 2 * i + 1);
Expand Down Expand Up @@ -1030,7 +1031,7 @@ struct MixMasterWidget : ModuleWidget {

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

// Inserts and CVs
Expand Down Expand Up @@ -1343,7 +1344,7 @@ struct MixMasterJrWidget : ModuleWidget {

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

// Inserts and CVs
Expand Down
16 changes: 9 additions & 7 deletions src/MixMaster/MixMaster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct GlobalInfo {
// panLawStereo: Stereo balance linear (default), Stereo balance equal power (+3dB boost since one channel lost), True pan (linear redistribution but is not equal power), Per-track
// momentaryCvButtons: 1 = yes (original rising edge only version), 0 = level sensitive (emulated with rising and falling detection)
// linearVolCvInputs: 0 means powN, 1 means linear
int panLawMono;// +0dB (no compensation), +3 (equal power), +4.5 (compromize), +6dB (linear, default)
int panLawMono;// +0dB (no compensation), +3 (equal power), +4.5 (compromise), +6dB (linear, default)
int8_t directOutsSkipGroupedTracks;// 0 no (default), 1 is yes
int8_t auxSendsMode;// 0 is pre-insert, 1 is post-insert, 2 is post-fader, 3 is post-solo, 4 is per-track choice
int groupsControlTrackSendLevels;// 0 = no, 1 = yes
Expand Down Expand Up @@ -53,7 +53,7 @@ struct GlobalInfo {
float *values20;
float maxTGFader;
float fadeRates[N_TRK + N_GRP];// reset and json done in tracks and groups. fade rates for tracks and groups
int groupUsage[N_GRP + 1];// bit 0 of first element shows if first track mapped to first group, etc... bitfields are mututally exclusive between all first 4 ints, last int is bitwise OR of first 4 ints.
int groupUsage[N_GRP + 1];// bit 0 of first element shows if first track mapped to first group, etc... bitfields are mutually exclusive between all first 4 ints, last int is bitwise OR of first 4 ints.


void clearLinked(int index) {linkBitMask &= ~(1 << index);}
Expand Down Expand Up @@ -1629,7 +1629,7 @@ struct MixerTrack {
dest->invertInput = invertInput;
dest->linkedFader = isLinked(&(gInfo->linkBitMask), trackNum);
}
void read(TrackSettingsCpBuffer *src) {
void read(const TrackSettingsCpBuffer *src) {
gainAdjust = src->gainAdjust;
*fadeRate = src->fadeRate;
fadeProfile = src->fadeProfile;
Expand Down Expand Up @@ -2101,26 +2101,25 @@ struct MixerAux {
float fadeGainScaledWithSolo;
float soloGain;


// no need to save, no reset
int auxNum;// 0 to 3
std::string ids;
GlobalInfo *gInfo;
Input *inInsert;
float *flMute;
float *flSolo0;
float *flGroup;
float *fadeRate;
float *fadeProfile;
float *taps;
int8_t* panLawStereoLocal;


int getAuxGroup() {return (int)(*flGroup + 0.5f);}
float calcFadeGain() {return *flMute >= 0.5f ? 0.0f : 1.0f;}
bool isFadeMode() {return *fadeRate >= GlobalConst::minFadeRate;}


void construct(int _auxNum, GlobalInfo *_gInfo, Input *_inputs, float* _values20, float* _taps, int8_t* _panLawStereoLocal) {
MixerAux(int _auxNum, GlobalInfo *_gInfo, Input *_inputs, float* _values20, float* _taps, int8_t* _panLawStereoLocal) {
auxNum = _auxNum;
ids = "id_a" + std::to_string(auxNum) + "_";
gInfo = _gInfo;
Expand All @@ -2131,8 +2130,11 @@ struct MixerAux {
fadeProfile = &_values20[auxNum + 16];
taps = _taps;
panLawStereoLocal = _panLawStereoLocal;

gainMatrixSlewers.setRiseFall(simd::float_4(GlobalConst::antipopSlewSlow)); // slew rate is in input-units per second (ex: V/s)
muteSoloGainSlewer.setRiseFall(GlobalConst::antipopSlewFast); // slew rate is in input-units per second (ex: V/s)

onReset();
}


Expand Down Expand Up @@ -2186,7 +2188,7 @@ struct MixerAux {
soloGain = calcSoloGain();
}

void process(float *mix, float *auxRetFadePanFadecv, bool eco) {// mixer aux
void process(float *mix, const float *auxRetFadePanFadecv, bool eco) {// mixer aux
// auxRetFadePan[0] points fader value,
// auxRetFadePan[4] points pan value,
// auxRetFadePan[8] points fader cv value,
Expand Down
6 changes: 3 additions & 3 deletions src/MixMaster/MixMasterWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct MixerInterchangeItem : MenuItem {


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

MixerInterchangeItem *interchangeItem = createMenuItem<MixerInterchangeItem>("MixMaster swap", RIGHT_ARROW);
Expand Down Expand Up @@ -198,7 +198,7 @@ void draw(const DrawArgs& args) override {

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

// Track labels (pull from module)
if (module->updateTrackLabelRequest != 0) {// pull request from module
Expand All @@ -219,7 +219,7 @@ void step() override {
int newSizeAdd = (module->auxExpanderPresent ? 3 : 0);
if (panelBorder->box.size.x != (box.size.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

0 comments on commit 752fdbe

Please sign in to comment.