Skip to content

Commit

Permalink
move compoly input channels calculation to complex base
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamPorcineFudgepuppy committed Jul 13, 2024
1 parent 04d4a14 commit ca89a22
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 44 deletions.
48 changes: 4 additions & 44 deletions src/ComputerscareNomplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,48 +133,6 @@ struct ComputerscareNomplexPumbers : ComputerscareComplexBase

}

std::array<int,2> getInputChannels(int index, int numFirst,int numSecond) {
int aInputCh = 1;
int bInputCh = 1;

int wrapMode = params[WRAP_MODE].getValue();

if(wrapMode == WRAP_NORMAL) {
/*
If monophonic, copy ch1 to all
Otherwise use the poly channels
*/
if(numFirst==1) {
aInputCh=0;
} else {
aInputCh=index;
}
if(numSecond==1) {
bInputCh=0;
} else {
bInputCh=index;
}

} else if(wrapMode == WRAP_CYCLE) {
// Cycle through the poly channels
aInputCh = index % numFirst;
bInputCh = index % numSecond;

} else if(wrapMode == WRAP_MINIMAL) {
// Do not copy channel 1 if monophonic
aInputCh=index;
bInputCh=index;

} else if(wrapMode == WRAP_STALL) {
// Go up to the maximum channel, and then use the final value for the rest
aInputCh=index>=numFirst ? numFirst-1 : index;
bInputCh=index>=numSecond ? numSecond-1 : index;
}

return {aInputCh,bInputCh};

}

void setOutputVoltages(int outIndex,int outMode,int compChannelIndex,float x, float y, float r, float theta) {
int outputBlock = compChannelIndex > 7 ? 1 : 0;
if(outMode==0) {
Expand Down Expand Up @@ -248,8 +206,10 @@ struct ComputerscareNomplexPumbers : ComputerscareComplexBase
float argumentOffsetKnob = params[ARGUMENT_INPUT_OFFSET].getValue();
float argumentTrimKnob = params[ARGUMENT_INPUT_TRIM].getValue();

int wrapMode = params[WRAP_MODE].getValue();

for(int rectInputCh = 0; rectInputCh < compolyChannelsRectIn; rectInputCh++) {
std::array<int,2> inputChannelIndices = getInputChannels(rectInputCh,numRealInputChannels,numImaginaryInputChannels);
std::vector<int> inputChannelIndices = getInputChannelIndices(rectInputCh,wrapMode,{numRealInputChannels,numImaginaryInputChannels});

int realInputCh=inputChannelIndices[0];
int imInputCh=inputChannelIndices[1];
Expand All @@ -265,7 +225,7 @@ struct ComputerscareNomplexPumbers : ComputerscareComplexBase
}

for(int polarInputCh = 0; polarInputCh < compolyChannelsPolarIn; polarInputCh++) {
std::array<int,2> inputChannelIndices = getInputChannels(polarInputCh,numModulusInputChannels,numArgumentInputChannels);
std::vector<int> inputChannelIndices = getInputChannelIndices(polarInputCh,wrapMode,{numModulusInputChannels,numArgumentInputChannels});

int modInputChannel=inputChannelIndices[0];
int argInputChannel=inputChannelIndices[1];
Expand Down
33 changes: 33 additions & 0 deletions src/complex/ComputerscareComplexBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,38 @@ struct ComputerscareComplexBase : ComputerscareMenuParamModule {

return outputCompolyphony;
}
std::vector<int> getInputChannelIndices(int outputIndex,int wrapMode, std::vector<int> channelCounts) {
std::vector<int> output;
for(int i = 0; i < channelCounts.size(); i++) {
int myInputChannelIndex=0;;
int myNumChannels = channelCounts[i];
if(wrapMode == WRAP_NORMAL) {
/*
If monophonic, copy ch1 to all
Otherwise use the poly channels
*/
if(myNumChannels == 1) {
myInputChannelIndex = 0;
} else {
myInputChannelIndex = outputIndex;
}
} else if(wrapMode == WRAP_CYCLE) {
// Cycle through the poly channels
myInputChannelIndex = outputIndex % myNumChannels;
} else if(wrapMode == WRAP_MINIMAL) {
// Do not copy channel 1 if monophonic
myInputChannelIndex = outputIndex;
} else if(wrapMode == WRAP_STALL) {
// Go up to the maximum channel, and then use the final value for the rest
myInputChannelIndex = outputIndex>myNumChannels-1 ? myNumChannels-1 : outputIndex;
}
//reverse
//pingpong
//random shuffled

output.push_back(myInputChannelIndex);
}
return output;
}

};

0 comments on commit ca89a22

Please sign in to comment.