commit 2fbb905c153133b78674001793f6f2a05721d7cf
parent cb2e3833f0ed64728f6f8875deb2177a02481677
Author: Adam M <[email protected]>
Date: Sun, 20 Jan 2019 23:32:45 -0600
Make transposies go work-work in peas-peas
Diffstat:
4 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp
@@ -183,16 +183,14 @@ ComputerscareILoveCookies() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LI
std::string str = "";
std::string randchar = "";
- int seed = rand();
float ru;
int length = 0;
-
for (int i = 0; i < numFields; i++) {
- srand(time(0));
- length = (rand()) % 12 + 2;
+
+ length = floor(randomUniform()*12) + 2;
str = "";
for(int j = 0; j < length; j++) {
- randchar = mainlookup[(rand()) % mainlookup.size()];
+ randchar = mainlookup[floor(randomUniform()*mainlookup.size())];
str = str + randchar;
ru = randomUniform();
if(ru < 0.1) {
@@ -412,7 +410,9 @@ struct WiggleKnobsMenuItem : MenuItem {
struct RandomizeTextFieldsMenuItem : MenuItem {
ComputerscareILoveCookies *cookies;
void onAction(EventAction &e) override {
+ srand(time(0));
cookies->randomizeTextFields();
+
}
};
diff --git a/src/ComputerscareOhPeas.cpp b/src/ComputerscareOhPeas.cpp
@@ -164,6 +164,7 @@ struct ComputerscareOhPeas : Module {
void ComputerscareOhPeas::step() {
float A,B,C,D,Q,a,b,c,d,octavePart;
+ int t;
for(int i = 0; i < numChannels; i++) {
a = params[SCALE_VAL+i].value;
@@ -177,7 +178,9 @@ void ComputerscareOhPeas::step() {
d = params[OFFSET_VAL+i].value;
D = (b*B + a)*A + (c*C + d);
- Q = quant.quantizeEven(D);
+
+ t = floor(params[GLOBAL_TRANSPOSE].value);
+ Q = quant.quantizeEven(D,t);
outputs[SCALED_OUTPUT + i].value = D;
outputs[QUANTIZED_OUTPUT + i].value = Q;
diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp
@@ -1158,6 +1158,7 @@ Quantizer::Quantizer(std::string intervals, int divisions, int trans) {
//printTokenVector(scaleParser.tokens);
numDivisions = divisions;
transpose=trans;
+ fNumDivisions = (float)numDivisions;
fTranspose = (float)transpose/(float)numDivisions;
mappedValues = generateMappedValues();
numSteps = (int) mappedValues.size();
@@ -1167,7 +1168,6 @@ Quantizer::Quantizer(std::string intervals, int divisions, int trans) {
std::vector<float> Quantizer::generateMappedValues() {
std::vector<float> output;
float sum = 0.f;
- float fNumDivisions = (float)numDivisions;
float currentVal = 0.f;
std::vector<Token> stack = scaleParser.tokens;
output.push_back(0.f);
@@ -1208,11 +1208,15 @@ float Quantizer::quantize(float input) {
float quantizedVal = quantizedPreTranspose + fTranspose;
return quantizedVal;
}
+float Quantizer::quantizeEven(float input,int iTranspose) {
+ float octavePart = floor(input);
+ float fractionalPart = input-octavePart;
+ float quantizedFractional = findEvenSpacingImpure(fractionalPart);
+ float quantizedPreTranspose = octavePart + quantizedFractional;
+ float quantizedVal = quantizedPreTranspose + ((float)iTranspose)/fNumDivisions;
+ return quantizedVal;
+}
float Quantizer::quantizeEven(float input) {
- float octavePart = floor(input);
- float fractionalPart = input-octavePart;
- float quantizedFractional = findEvenSpacingImpure(fractionalPart);
- float quantizedPreTranspose = octavePart + quantizedFractional;
- float quantizedVal = quantizedPreTranspose + fTranspose;
- return quantizedVal;
+ return quantizeEven(input,0);
}
+
diff --git a/src/dtpulse.hpp b/src/dtpulse.hpp
@@ -121,9 +121,10 @@ class Quantizer {
Quantizer();
float quantize(float val);
float quantizeEven(float val);
+ float quantizeEven(float val, int iTranspose);
float findEvenSpacingValue(float input, std::vector<float> allowedValues);
float findEvenSpacingImpure(float input);
-
+ float fNumDivisions;
std::vector<float> mappedValues;
int numDivisions;
int transpose;