Skip to content

Commit

Permalink
pass vectors by ref rather than by value for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamPorcineFudgepuppy committed Jul 19, 2024
1 parent 0b44d32 commit 7483da8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
21 changes: 10 additions & 11 deletions src/ComputerscareComplexTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,16 @@ struct ComputerscareComplexTransformer : ComputerscareComplexBase {
configOutput<cpx::CompolyPortInfo<MAIN_OUTPUT_MODE,1>>(COMPOLY_MAIN_OUT_B, "f(z)");

}

void process(const ProcessArgs &args) override {
ComputerscarePolyModule::checkCounter();
int wrapMode = 0;

int compolyphonyKnobSetting = params[COMPOLY_CHANNELS].getValue();
int mainInputMode = params[MAIN_INPUT_MODE].getValue();

//+.6%
//std::vector<std::vector <int>> inputCompolyphony = {{2,2}};
std::vector<std::vector <int>> inputCompolyphony = getInputCompolyphony({MAIN_INPUT_MODE},{MAIN_INPUT});


Expand All @@ -103,21 +106,17 @@ struct ComputerscareComplexTransformer : ComputerscareComplexBase {
math::Vec scaleRect = Vec(scaleX,scaleY);



std::vector<float> complexQuadRep;

for (int complexOutputChannel = 0; complexOutputChannel < compolyChannelsMainOutput; complexOutputChannel++) {
// DEBUG("%i",complexOutputChannel);


std::vector<float> complexQuadRep = getComplexVoltage(complexOutputChannel, MAIN_INPUT,mainInputMode, wrapMode, inputCompolyphony);
complexQuadRep = getComplexVoltage(complexOutputChannel, MAIN_INPUT,mainInputMode, wrapMode, inputCompolyphony);

float x = complexQuadRep[0];
float y = complexQuadRep[1];
float r = complexQuadRep[2];
float theta = complexQuadRep[3];
float x = complexQuadRep[0];
float y = complexQuadRep[1];
float r = complexQuadRep[2];
float theta = complexQuadRep[3];

setOutputVoltages(COMPOLY_MAIN_OUT_A,mainOutputMode,complexOutputChannel,x,y,r,theta);
//setOutputVoltages(COMPOLY_MAIN_OUT_A,mainOutputMode,complexOutputChannel,1,1,1,1);
setOutputVoltages(COMPOLY_MAIN_OUT_A,mainOutputMode,complexOutputChannel,x,y,r,theta);
}


Expand Down
7 changes: 4 additions & 3 deletions src/complex/ComputerscareComplexBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct ComputerscareComplexBase : ComputerscareMenuParamModule {
-port0, ch3
*/

std::vector<float> getComplexVoltageFromSeparatedInput(int outputIndex, int firstPortID, int inputMode,int wrapMode,std::vector <int> inputCompolyphony) {
std::vector<float> getComplexVoltageFromSeparatedInput(int outputIndex, int firstPortID, int inputMode,int wrapMode,std::vector <int>& inputCompolyphony) {
std::vector<float> output = {};

int firstPortIndex = outputIndex;
Expand All @@ -173,7 +173,7 @@ struct ComputerscareComplexBase : ComputerscareMenuParamModule {

return output;
}
std::vector<float> getComplexVoltageFromInterleavedInput(int outputIndex, int firstPortID, int inputMode,int wrapMode,std::vector<int> inputCompolyphony) {
std::vector<float> getComplexVoltageFromInterleavedInput(int outputIndex, int firstPortID, int inputMode,int wrapMode,std::vector<int>& inputCompolyphony) {
std::vector<float> output = {};
int portIndex = outputIndex >= 8 ? firstPortID + 1 : firstPortID;
int relativeOutputChannelIndex = outputIndex % 8;
Expand Down Expand Up @@ -216,7 +216,8 @@ struct ComputerscareComplexBase : ComputerscareMenuParamModule {



std::vector<float> getComplexVoltage(int outputIndex, int firstPortID, int inputMode,int wrapMode,std::vector<std::vector <int>> inputCompolyphony) {
std::vector<float> getComplexVoltage(int outputIndex, int firstPortID, int inputMode,int wrapMode,std::vector<std::vector <int>>& inputCompolyphony) {
//return {0.f,1.f,2.f,3.f};
std::vector<float> mainInputVoltages;
if(inputMode==RECT_INTERLEAVED || inputMode == POLAR_INTERLEAVED) {
mainInputVoltages = getComplexVoltageFromInterleavedInput(outputIndex, firstPortID,inputMode, wrapMode, inputCompolyphony[0]);
Expand Down

0 comments on commit 7483da8

Please sign in to comment.