Skip to content

Commit

Permalink
more small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcBoule committed Oct 14, 2023
1 parent a0c2097 commit 0c2845e
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/MindMeldModular.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern int8_t pmAllowMouseTileMove;// PatchMaster allow ctrl/cmd click to move t
// General objects

union PackedBytes4 {
int32_t cc1;
int32_t cc1 = 0;
int8_t cc4[4];
};

Expand Down
8 changes: 5 additions & 3 deletions src/MixMaster/AuxExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ struct AuxExpander : Module {
int8_t momentCvGroupMuteLocal[N_GRP];
float auxFadeRatesAndProfiles[8];// first 4 are fade rates, last 4 are fade profiles, all same standard as mixmaster
alignas(4) char auxLabels[4 * 4 + 4];// 4 chars per label, 4 aux labels, null terminate the end the whole array only, pad with three extra chars for alignment
AuxspanderAux aux[4];
std::vector<AuxspanderAux> aux;// size 4
float panCvLevels[4];// 0 to 1.0f

// No need to save, with reset
int updateTrackLabelRequest;// 0 when nothing to do, 1 for read names in widget
int updateAuxLabelRequest;// 0 when nothing to do, 1 for read names in widget
int refreshCounter20;
float srcLevelsVus[4][4];// first index is aux number, 2nd index is a vuValue (organized according to VuMeters::VuIds)
float paramRetFaderWithCv[4];// for cv pointers in aux retrun faders
float paramRetFaderWithCv[4];// for cv pointers in aux return faders
simd::float_4 globalSendsWithCV;
bool globalSendsCvConnected;
float indivTrackSendWithCv[N_TRK * 4];
Expand Down Expand Up @@ -217,8 +217,10 @@ struct AuxExpander : Module {
groupSendVcaGains[i] = simd::float_4::zero();
}
auxLabels[4 * 4] = 0;

aux.reserve(4);
for (int i = 0; i < 4; i++) {
aux[i].construct(i, &inputs[0], &params[0], &(auxLabels[4 * i]), &vuColorThemeLocal.cc4[i], &directOutsModeLocal.cc4[i], &panLawStereoLocal.cc4[i], &dispColorAuxLocal.cc4[i], &panCvLevels[i], &auxFadeRatesAndProfiles[i]);
aux.push_back(AuxspanderAux(i, &inputs[0], &params[0], &(auxLabels[4 * i]), &vuColorThemeLocal.cc4[i], &directOutsModeLocal.cc4[i], &panLawStereoLocal.cc4[i], &dispColorAuxLocal.cc4[i], &panCvLevels[i], &auxFadeRatesAndProfiles[i]));
}

onReset();
Expand Down
38 changes: 20 additions & 18 deletions src/MixMaster/AuxExpander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@ struct AuxspanderAux {

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

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

// no need to save, no reset
int auxNum = 0;
char *auxLabel = nullptr;
int auxNum;
char *auxLabel;
std::string ids;
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
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


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) {
AuxspanderAux(int _auxNum, Input *_inputs, Param *_params, char* _auxLabel, int8_t *_vuColorThemeLocal, int8_t *_directOutsModeLocal, int8_t *_panLawStereoLocal, int8_t *_dispColorAuxLocal, float *_panCvLevel, float *_auxFadeRatesAndProfile) {
auxNum = _auxNum;
auxLabel = _auxLabel;
ids = "id_x" + std::to_string(auxNum) + "_";
Expand All @@ -64,6 +64,8 @@ struct AuxspanderAux {
trackAuxSendParam = &_params[TRACK_AUXSEND_PARAMS + auxNum];// all spaced out by 4, N_TRK of them
groupAuxSendParam = &_params[GROUP_AUXSEND_PARAMS + auxNum];// all spaced out by 4, N_GRP of them
globalAuxParam = &_params[GLOBAL_AUXMUTE_PARAMS + auxNum];// all spaced out by 4: mute, solo, group, send, pan, return

onReset();
}


Expand Down
2 changes: 1 addition & 1 deletion src/MixMaster/MixMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct MixMaster : Module {
MfaExpInterface rightMessages[2];// messages from aux-expander, see MixerCommon.hpp

// Constants
int numChannels16 = 16;// avoids warning that happens when hardcode 16 (static const or directly use 16 in code below)
const int numChannels16 = 16;// avoids warning that happens when hardcode 16 (static const or directly use 16 in code below)

// Need to save, no reset
// none
Expand Down
86 changes: 43 additions & 43 deletions src/MixMaster/MixerCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum GTOL_IDS {
struct GlobalToLocalOp {
int8_t opCodeMixer = GTOL_NOP;;// see GTOL_IDS
int8_t opCodeExpander = GTOL_NOP;// see GTOL_IDS
int8_t operand;// the global value that we want to be set in all the local values
int8_t operand = 0;// the global value that we want to be set in all the local values

void setOp(int8_t _opCode, int8_t _operand) {
operand = _operand;// set this first for safe thread behavior
Expand All @@ -43,38 +43,38 @@ template <int N_TRK, int N_GRP>
struct TAfmExpInterface {// messages to expander from mother (data is in expander, mother writes into expander)
// Fast (sample-rate)
bool updateSlow = false;
float auxSends[(N_TRK + N_GRP) * 2] = {0.0f};
float auxSends[(N_TRK + N_GRP) * 2] = {};
int vuIndex = 0;
float vuValues[4] = {0.0f};
float vuValues[4] = {};

// Slow (sample-rate / 256), no need to init
PackedBytes4 colorAndCloak;
PackedBytes4 directOutPanStereoMomentCvLinearVol;
uint32_t muteAuxSendWhenReturnGrouped;
uint16_t ecoMode;// all 1's means yes, 0 means no
int32_t trackMoveInAuxRequest;// 0 when nothing to do, {dest,src} packed when a move is requested
int8_t trackOrGroupResetInAux;// -1 when nothing to do, 0 to N_TRK-1 for track reset, N_TRK to N_TRK+N_GRP-1 for group reset
alignas(4) char trackLabels[4 * (N_TRK + N_GRP)];
uint32_t muteAuxSendWhenReturnGrouped = 0;
uint16_t ecoMode = 0;// all 1's means yes, 0 means no
int32_t trackMoveInAuxRequest = 0;// 0 when nothing to do, {dest,src} packed when a move is requested
int8_t trackOrGroupResetInAux = 0;// -1 when nothing to do, 0 to N_TRK-1 for track reset, N_TRK to N_TRK+N_GRP-1 for group reset
alignas(4) char trackLabels[4 * (N_TRK + N_GRP)] = {};
PackedBytes4 trackDispColsLocal[N_TRK / 4 + 1];// only valid when colorAndCloak.cc4[dispColorGlobal] >= numDispThemes
float auxRetFadeGains[4];
float srcMuteGhost[4];
float auxRetFadeGains[4] = {};
float srcMuteGhost[4] = {};
GlobalToLocalOp globalToLocalOp;
};


struct MfaExpInterface {// messages to mother from expander (data is in mother, expander writes into mother)
// Fast (sample-rate)
bool updateSlow = false;
float auxReturns[8] = {0.0f};
float auxRetFaderPanFadercv[12] = {0.0f};
float auxReturns[8] = {};
float auxRetFaderPanFadercv[12] = {};

// Slow (sample-rate / 256), no need to init
PackedBytes4 directOutsModeLocalAux;
PackedBytes4 stereoPanModeLocalAux;
PackedBytes4 auxVuColors;
PackedBytes4 auxDispColors;
float values20[20];// Aux mute, solo, group, fade rate, fade profile; 4 consective floats for each (one per aux)
alignas(4) char auxLabels[4 * 4];
float values20[20] = {};// Aux mute, solo, group, fade rate, fade profile; 4 consective floats for each (one per aux)
alignas(4) char auxLabels[4 * 4] = {};
};


Expand Down Expand Up @@ -137,37 +137,37 @@ float updateFadeGain(float fadeGain, float target, float *fadeGainX, float *fade

struct TrackSettingsCpBuffer {
// first level of copy paste (copy copy-paste of track settings)
float gainAdjust;
float fadeRate;
float fadeProfile;
float hpfCutoffFreq;// !! user must call filters' setCutoffs manually when copy pasting these
float lpfCutoffFreq;// !! user must call filters' setCutoffs manually when copy pasting these
int8_t directOutsMode;
int8_t auxSendsMode;
int8_t panLawStereo;
int8_t vuColorThemeLocal;
int8_t filterPos;
int8_t dispColorLocal;
int8_t momentCvMuteLocal;
int8_t momentCvSoloLocal;
int8_t polyStereo;
float panCvLevel;
float stereoWidth;
int8_t invertInput;
bool linkedFader;
float gainAdjust = 0.0f;
float fadeRate = 0.0f;
float fadeProfile = 0.0f;
float hpfCutoffFreq = 0.0f;// !! user must call filters' setCutoffs manually when copy pasting these
float lpfCutoffFreq = 0.0f;// !! user must call filters' setCutoffs manually when copy pasting these
int8_t directOutsMode = 0;
int8_t auxSendsMode = 0;
int8_t panLawStereo = 0;
int8_t vuColorThemeLocal = 0;
int8_t filterPos = 0;
int8_t dispColorLocal = 0;
int8_t momentCvMuteLocal = 0;
int8_t momentCvSoloLocal = 0;
int8_t polyStereo = 0;
float panCvLevel = 0.0f;
float stereoWidth = 0.0f;
int8_t invertInput = 0;
bool linkedFader = false;

// second level of copy paste (for track re-ordering)
float paGroup;
float paFade;
float paMute;
float paSolo;
float paPan;
char trackName[4];// track names are not null terminated in MixerTracks
float fadeGain;
float target;
float fadeGainX;
float fadeGainXr;
float fadeGainScaled;
float paGroup = 0.0f;
float paFade = 0.0f;
float paMute = 0.0f;
float paSolo = 0.0f;
float paPan = 0.0f;
char trackName[4] = {};// track names are not null terminated in MixerTracks
float fadeGain = 0.0f;
float target = 0.0f;
float fadeGainX = 0.0f;
float fadeGainXr = 0.0f;
float fadeGainScaled = 0.0f;
};


Expand Down
24 changes: 18 additions & 6 deletions src/MixMaster/MixerWidgets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,10 +803,14 @@ struct TrackDisplay : EditableDisplayBase {
EditableDisplayBase::onButton(e);
}
void onChange(const event::Change &e) override {
(*((uint32_t*)(tracks[trackNumSrc].trackName))) = 0x20202020;
for (int i = 0; i < std::min(4, (int)text.length()); i++) {
// (*((uint32_t*)(tracks[trackNumSrc].trackName))) = 0x20202020;
int i = 0;
for ( ;i < std::min(4, (int)text.length()); i++) {
tracks[trackNumSrc].trackName[i] = text[i];
}
for ( ;i < 4; i++) {
tracks[trackNumSrc].trackName[i] = 0x20;
}
EditableDisplayBase::onChange(e);
};
};
Expand Down Expand Up @@ -936,10 +940,14 @@ struct GroupDisplay : EditableDisplayBase {
EditableDisplayBase::onButton(e);
}
void onChange(const event::Change &e) override {
(*((uint32_t*)(srcGroup->groupName))) = 0x20202020;
for (int i = 0; i < std::min(4, (int)text.length()); i++) {
// (*((uint32_t*)(srcGroup->groupName))) = 0x20202020;
int i = 0;
for ( ;i < std::min(4, (int)text.length()); i++) {
srcGroup->groupName[i] = text[i];
}
for ( ;i < 4; i++) {
srcGroup->groupName[i] = 0x20;
}
EditableDisplayBase::onChange(e);
};
};
Expand Down Expand Up @@ -1056,10 +1064,14 @@ struct AuxDisplay : EditableDisplayBase {
EditableDisplayBase::onButton(e);
}
void onChange(const event::Change &e) override {
(*((uint32_t*)(auxName))) = 0x20202020;
for (int i = 0; i < std::min(4, (int)text.length()); i++) {
// (*((uint32_t*)(auxName))) = 0x20202020;
int i = 0;
for ( ;i < std::min(4, (int)text.length()); i++) {
auxName[i] = text[i];
}
for ( ;i < 4; i++) {
auxName[i] = 0x20;
}
EditableDisplayBase::onChange(e);
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/PatchSet/PatchMasterBlank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ struct PatchMasterBlankWidget : ModuleWidget {

PatchMasterBlankWidget(PatchMasterBlank *module) {
setModule(module);
svgPanel = static_cast<SvgPanel*>(getPanel());
panelBorder = findBorder(svgPanel->fb);
svgs[0] = APP->window->loadSvg(asset::plugin(pluginInstance, "res/dark/patchset/pm-vsep-bg.svg"));
setPanel(svgs[0]);
svgs[1] = nullptr;
svgPanel = static_cast<SvgPanel*>(getPanel());
panelBorder = findBorder(svgPanel->fb);
lastFacePlate = 0;
}

Expand Down

0 comments on commit 0c2845e

Please sign in to comment.