computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit e0e832670539ec5913a513e9e8f1dcce6751767c
parent 01237b1660c5a3cdc8c3ec9462792443af52583a
Author: Adam M <aemalone@gmail.com>
Date:   Fri, 11 Oct 2019 18:10:52 -0500

Merge branch 'master' into laundrypoly

# Conflicts:
#	src/dtpulse.cpp
#	src/dtpulse.hpp

Diffstat:
MREADME.MD | 4++--
Msrc/dtpulse.cpp | 57++++++++++++++++++++++++++++++++++++++++++++-------------
Msrc/dtpulse.hpp | 2++
3 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/README.MD b/README.MD @@ -13,7 +13,7 @@ The scale for quantization is programmed via the text field. Oh Peas! expects n ### Input Jacks: -**Main Input (input, _A_):** +**Main Input (input, _A_)** **Range CV (range, _B_):** Multiplies the input value, attenuverted by the small Range CV knob @@ -81,7 +81,7 @@ abcdef@3 abc ## Randomization -Enclosing values (lowercase letter, uppercase letter, or exact voltage) in curly braces {} will randomly select one of the values with equal probability. For example, ~{ab}~ will choose either "a" or "b" at each clock step. ~{g<2.55>}~ will output either the value of knob "g" or 2.55 volts with equal probability. +Enclosing values (lowercase letter, uppercase letter, or exact voltage) in curly braces {} will randomly select one of the values with equal probability. For example, `{ab}` will choose either `a` or `b` at each clock step. `{g<2.55>}` will output either the value of knob `g` or `2.55` volts with equal probability. ## Square Bracket Expansion diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp @@ -655,6 +655,24 @@ void Parser::setForLaundryPoly() { printf("setForLaundryPoly\n"); printTokenVector(tokenStack); } +void Parser::setForQuantizer() { +printf("horseman\n"); + if(tokens.size() > 0) { +printf("pluto mcfeely\n"); + currentIndex=0; + printTokenVector(tokens); + printTokenVector(tokenStack); + tokenStack={}; + printTokenVector(tokens); + setForExactIntegers(tokens[0]); + printf("got there\n"); + printTokenVector(tokenStack); + if(!inError) { + currentIndex=0; + tokens=tokenStack; + } + } +} void Parser::setForLaundry() { std::vector<std::string> laundryBinaryOp = {"Plus","Minus","Asterix","Backslash","Caret","Ampersand"}; std::vector<std::string> laundryInterleaveAny = {"Letter", "Integer", "ChanceOfInteger", "Digit", "LeftParen", "RightParen", "Channel"}; @@ -1293,6 +1311,11 @@ void whoKnowsQuantize(std::string input) { //float in = std::stof(input); //printf("closest: %f\n",q.quantize(in)); //printf("even : %f\n",q.quantizeEven(in)); + Quantizer q = Quantizer(input,12,0); + q.print(); + //float in = std::stof(input); + //printf("closest: %f\n",q.quantize(in)); + //printf("even : %f\n",q.quantizeEven(in)); } Quantizer::Quantizer() { Quantizer("2212221", 12, 0); @@ -1310,19 +1333,23 @@ Quantizer::Quantizer(std::string intervals, int divisions, int trans) { //printFloatVector(mappedValues); } std::vector<float> Quantizer::generateMappedValues() { - std::vector<float> output; - float sum = 0.f; - float currentVal = 0.f; - std::vector<Token> stack = scaleParser.tokens; - output.push_back(0.f); - for (unsigned int i = 0; i < stack.size(); i++) { - if (stack[i].type == "Digit") { - sum += std::stof(stack[i].value); - currentVal = sum / fNumDivisions; - output.push_back(currentVal); - } - } - return output; + std::vector<float> output; + float sum = 0.f; + float currentVal = 0.f; + printf("tokens size %i\n",scaleParser.tokens.size()); + scaleParser.setForQuantizer(); + std::vector<Token> stack = scaleParser.tokens; + +printf("tokens size after %i\n",scaleParser.tokens.size()); + output.push_back(0.f); + for(unsigned int i = 0; i < stack.size(); i++) { + if(stack[i].type=="Digit" || stack[i].type=="Integer") { + sum += std::stof(stack[i].value); + currentVal = sum/fNumDivisions; + output.push_back(currentVal); + } + } + return output; } float Quantizer::findEvenSpacingValue(float input, std::vector<float> allowedValues) { return allowedValues[floor(input * allowedValues.size())]; @@ -1363,6 +1390,10 @@ float Quantizer::quantizeEven(float input, int iTranspose) { float Quantizer::quantizeEven(float input) { return quantizeEven(input, 0); } + +void Quantizer::print() { + printFloatVector(mappedValues); +} std::string getByteString(float f) { unsigned char const * p = reinterpret_cast<unsigned char const *>(&f); diff --git a/src/dtpulse.hpp b/src/dtpulse.hpp @@ -46,6 +46,7 @@ class Parser { void setForCookies(); void setForLaundry(); void setForLaundryPoly(); + void setForQuantizer(); void skipToken(); void setExactValue(Token t); void setForExactIntegers(Token t); @@ -142,6 +143,7 @@ class Quantizer { bool parseError; int numSteps; float fTranspose; + void print(); private: Parser scaleParser; float findClosestValue(float input, std::vector<float> allowedValues);