#include "INHK_Pot3.h"
#include "Wave.h"
// Potentiometer pot1(A0);
// Potentiometer pot2(A1);
// Potentiometer pot3(A2);
Wave carrierWave;
float carrier;
float resultingWave;
//float aa = 1.0; // coefficient for first exponential function to convert linear input to logaritmic output: y = a * x^2
float a = 0.2; // coefficients for second exponential function to convert linear input to logaritmic output y = a * b^(x/c)
float b = 3.3; // see: https://www.desmos.com/calculator/vhwitrlu6a and https://www.desmos.com/calculator/tngftxzw94
float c = 43.0; // int the function "y = a * b^(x/c)" this is actually the c in "(x/c)""
void setup() {
Serial.begin(115200); // Initialize serial communication
}
void loop() {
// carrier_amplitude = pot1.readValue(); // use this to control amplitude with pot
// carrier_frequency = pot2.readValue(); // use this to control frequency with pot
// carrier_offset = pot3.readValue(); // use this to control offset with pot
carrierWave.setAmplitude(255); // updates amplitude with pot reading
carrierWave.setFrequency(10); // updates frequency with pot reading, use only with sine,saw,upSaw and triangle waves
carrierWave.setOffset(0); // updates offset with pot reading
carrier = carrierWave.sawUpValue();
// float normalizedInput = carrier / 255.0; // first exponential function to convert linear input to logaritmic output: y = a * x^2
// float scaledValue = aa * normalizedInput * normalizedInput;
// int outputValue = scaledValue * 255;
float power = carrier/c;
int outputValue = a*(pow(b, power)); // second - probably better - exponential function to convert linear input to logaritmic output y = a * b^(x/c)
Serial.print("Carrier Wave: ");
Serial.print(carrier);
Serial.print(" , ");
Serial.print("displayValue: ");
Serial.print(outputValue);
Serial.println();
}