commit ba674ee13877e6502a33dea66991a7cae004fe6d
parent 0f27080c2368737572dd4c4fcfc3cffe88dcfe8d
Author: Adam M <[email protected]>
Date: Fri, 17 Apr 2020 00:36:32 -0500
semicolon separate formulas for laundry soup to make polyphony
Diffstat:
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/ComputerscareLaundrySoup.cpp b/src/ComputerscareLaundrySoup.cpp
@@ -237,7 +237,8 @@ struct ComputerscareLaundrySoup : Module {
if (currentFormula[index].find("#") != std::string::npos) {
channelCount[index] = 16;
} else {
- channelCount[index] = 1;
+ size_t n = std::count(currentFormula[index].begin(), currentFormula[index].end(), ';');
+ channelCount[index] = std::min((int)n+1,16);
}
} else {
channelCount[index] = channelCountEnum[index];
diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp
@@ -396,8 +396,12 @@ LaundryPoly::LaundryPoly(std::string formula) {
bool myInError=false;
maxSteps=-1;
int ns;
+ std::vector<std::string> semisep = split(formula,';');
+ int semilen = semisep.size();
+ printf("semilen:%i\n",semilen);
for (int i = 0; i < 16; i++ ) {
- newFormula = formula;
+ //newFormula = formula;
+ newFormula=semilen==0 ? formula : semisep[i%semilen];//i%semilen];
replaceAll(newFormula, "#", "<" + std::to_string(static_cast<long long>(i + 1)) + ">");
lss[i] = LaundrySoupSequence(newFormula);
ns = lss[i].numSteps;
@@ -1431,3 +1435,14 @@ int myPow(int x, int p)
if (p%2 == 0) return tmp * tmp;
else return x * tmp * tmp;
}
+std::vector<std::string> split(std::string strToSplit, char delimeter)
+{
+ std::stringstream ss(strToSplit);
+ std::string item;
+ std::vector<std::string> splittedStrings;
+ while (std::getline(ss, item, delimeter))
+ {
+ splittedStrings.push_back(item);
+ }
+ return splittedStrings;
+}
diff --git a/src/dtpulse.hpp b/src/dtpulse.hpp
@@ -198,3 +198,4 @@ void replaceAll(std::string& str, const std::string& from, const std::string& to
float mapChannelCountToVoltage(int ch);
int mapVoltageToChannelCount(float vv);
int myPow(int x, int p);
+std::vector<std::string> split(std::string strToSplit, char delimeter);