Skip to content

Commit

Permalink
implement tracks and groups with std vector
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcBoule committed Oct 15, 2023
1 parent dc89d2f commit ca9587f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/MixMaster/AuxExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct AuxExpander : Module {
};

enum InputIds {
ENUMS(RETURN_INPUTS, 2 * 4),// must be first element (see AuxspanderAux.construct()). Mapping: left A, right A, left B, right B, left C, right C, left D, right D
ENUMS(RETURN_INPUTS, 2 * 4),// must be first element (see AuxspanderAux constructor). Mapping: left A, right A, left B, right B, left C, right C, left D, right D
ENUMS(POLY_AUX_AD_CV_INPUTS, N_GRP),// size happens to coincide with N_GRP
POLY_AUX_M_CV_INPUT,
POLY_GRPS_AD_CV_INPUT,// Mapping: 1A, 2A, 3A, 4A, 1B, etc
Expand Down
14 changes: 8 additions & 6 deletions src/MixMaster/MixMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ struct MixMaster : Module {
// Need to save, with reset
alignas(4) char trackLabels[4 * (N_TRK + N_GRP) + 4];// 4 chars per label, 16 (8) tracks and 4 (2) groups means 20 (10) labels, null terminate the end the whole array only, pad with three extra chars for alignment
GlobalInfo* gInfo;
MixerTrack tracks[N_TRK];
MixerGroup groups[N_GRP];
std::vector<MixerTrack> tracks;// size N_TRK
std::vector<MixerGroup> groups;// size N_GRP
std::vector<MixerAux> aux;// size 4
MixerMaster* master;

Expand Down Expand Up @@ -232,11 +232,13 @@ struct MixMaster : Module {

gInfo = new GlobalInfo(&params[0], values20);
trackLabels[4 * (N_TRK + N_GRP)] = 0;
tracks.reserve(N_TRK);
for (int i = 0; i < N_TRK; i++) {
tracks[i].construct(i, gInfo, &inputs[0], &params[0], &(trackLabels[4 * i]), &trackTaps[i << 1], groupTaps, &trackInsertOuts[i << 1]);
tracks.push_back(MixerTrack(i, gInfo, &inputs[0], &params[0], &(trackLabels[4 * i]), &trackTaps[i << 1], groupTaps, &trackInsertOuts[i << 1]));
}
groups.reserve(N_GRP);
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]);
groups.push_back(MixerGroup(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++) {
Expand Down Expand Up @@ -1061,7 +1063,7 @@ struct MixMasterWidget : ModuleWidget {
// trackDisplays[i]->tabNextFocus = // done after the for loop
trackDisplays[i]->colorAndCloak = &(module->gInfo->colorAndCloak);
trackDisplays[i]->dispColorLocal = &(module->tracks[i].dispColorLocal);
trackDisplays[i]->tracks = module->tracks;
trackDisplays[i]->tracks = &(module->tracks[0]);
trackDisplays[i]->trackNumSrc = i;
trackDisplays[i]->auxExpanderPresentPtr = &(module->auxExpanderPresent);
trackDisplays[i]->numTracks = N_TRK;
Expand Down Expand Up @@ -1373,7 +1375,7 @@ struct MixMasterJrWidget : ModuleWidget {
// trackDisplays[i]->tabNextFocus = // done after the for loop
trackDisplays[i]->colorAndCloak = &(module->gInfo->colorAndCloak);
trackDisplays[i]->dispColorLocal = &(module->tracks[i].dispColorLocal);
trackDisplays[i]->tracks = module->tracks;
trackDisplays[i]->tracks = &(module->tracks[0]);
trackDisplays[i]->trackNumSrc = i;
trackDisplays[i]->auxExpanderPresentPtr = &(module->auxExpanderPresent);
trackDisplays[i]->numTracks = N_TRK;
Expand Down
34 changes: 21 additions & 13 deletions src/MixMaster/MixMaster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ struct MixerGroup {
bool isFadeMode() {return *fadeRate >= GlobalConst::minFadeRate;}


void construct(int _groupNum, GlobalInfo *_gInfo, Input *_inputs, Param *_params, char* _groupName, float* _taps, float* _insertOuts) {
MixerGroup(int _groupNum, GlobalInfo *_gInfo, Input *_inputs, Param *_params, char* _groupName, float* _taps, float* _insertOuts) {
groupNum = _groupNum;
ids = "id_g" + std::to_string(groupNum) + "_";
gInfo = _gInfo;
Expand All @@ -868,6 +868,7 @@ struct MixerGroup {
groupName = _groupName;
taps = _taps;
insertOuts = _insertOuts;

fadeRate = &(_gInfo->fadeRates[N_TRK + groupNum]);
gainMatrixSlewers.setRiseFall(simd::float_4(GlobalConst::antipopSlewSlow)); // slew rate is in input-units per second (ex: V/s)
gainAdjustSlewer.setRiseFall(GlobalConst::antipopSlewFast); // slew rate is in input-units per second (ex: V/s)
Expand All @@ -877,6 +878,8 @@ struct MixerGroup {
hpFilter[i].setParameters(true, 0.1f);
lpFilter[i].setParameters(false, 0.4f);
}

onReset();
}


Expand All @@ -900,19 +903,21 @@ struct MixerGroup {


void resetNonJson() {
panMatrix = 0.0f;
gainMatrix = 0.0f;
volCv = 0.0f;
gainMatrixSlewers.reset();
gainAdjustSlewer.reset();
stereoWidthSlewer.reset();
muteSoloGainSlewer.reset();
setHPFCutoffFreq(paHpfCutoff->getValue());// off
setLPFCutoffFreq(paLpfCutoff->getValue());// off
// lastHpfCutoff; automatically set in setHPFCutoffFreq()
// lastLpfCutoff; automatically set in setLPFCutoffFreq()
for (int i = 0; i < 2; i++) {
hpFilter[i].reset();
lpFilter[i].reset();
}
// lastHpfCutoff; automatically set in setHPFCutoffFreq()
// lastLpfCutoff; automatically set in setLPFCutoffFreq()
setHPFCutoffFreq(paHpfCutoff->getValue());// off
setLPFCutoffFreq(paLpfCutoff->getValue());// off
panMatrix = 0.0f;
gainMatrix = 0.0f;
volCv = 0.0f;
oldPan = -10.0f;
oldPanSignature.cc1 = 0xFFFFFFFF;
vu.reset();
Expand Down Expand Up @@ -1381,7 +1386,7 @@ struct MixerTrack {
bool isFadeMode() {return *fadeRate >= GlobalConst::minFadeRate;}


void construct(int _trackNum, GlobalInfo *_gInfo, Input *_inputs, Param *_params, char* _trackName, float* _taps, float* _groupTaps, float* _insertOuts) {
MixerTrack(int _trackNum, GlobalInfo *_gInfo, Input *_inputs, Param *_params, char* _trackName, float* _taps, float* _groupTaps, float* _insertOuts) {
trackNum = _trackNum;
ids = "id_t" + std::to_string(trackNum) + "_";
gInfo = _gInfo;
Expand All @@ -1402,6 +1407,7 @@ struct MixerTrack {
taps = _taps;
groupTaps = _groupTaps;
insertOuts = _insertOuts;

fadeRate = &(_gInfo->fadeRates[trackNum]);
gainMatrixSlewers.setRiseFall(simd::float_4(GlobalConst::antipopSlewSlow)); // slew rate is in input-units per second (ex: V/s)
inGainSlewer.setRiseFall(GlobalConst::antipopSlewFast); // slew rate is in input-units per second (ex: V/s)
Expand All @@ -1411,6 +1417,8 @@ struct MixerTrack {
hpFilter[i].setParameters(true, 0.1f);
lpFilter[i].setParameters(false, 0.4f);
}

onReset();
}


Expand Down Expand Up @@ -1444,14 +1452,14 @@ struct MixerTrack {
inGainSlewer.reset();
stereoWidthSlewer.reset();
muteSoloGainSlewer.reset();
setHPFCutoffFreq(paHpfCutoff->getValue());// off
setLPFCutoffFreq(paLpfCutoff->getValue());// off
// lastHpfCutoff; automatically set in setHPFCutoffFreq()
// lastLpfCutoff; automatically set in setLPFCutoffFreq()
for (int i = 0; i < 2; i++) {
hpFilter[i].reset();
lpFilter[i].reset();
}
// lastHpfCutoff; automatically set in setHPFCutoffFreq()
// lastLpfCutoff; automatically set in setLPFCutoffFreq()
setHPFCutoffFreq(paHpfCutoff->getValue());// off
setLPFCutoffFreq(paLpfCutoff->getValue());// off
oldPan = -10.0f;
oldPanSignature.cc1 = 0xFFFFFFFF;
vu.reset();
Expand Down

0 comments on commit ca9587f

Please sign in to comment.