KIK 01 Prototype 05
Dependencies: AverageMCP3008 mbed-rtos mbed mcp3008
Fork of KIK01_Proto03 by
Diff: main.cpp
- Revision:
- 29:947992b9904f
- Parent:
- 28:387c5a6d5206
- Child:
- 30:1291e20b1c53
--- a/main.cpp Thu Oct 19 07:15:45 2017 +0000 +++ b/main.cpp Thu Oct 19 07:57:15 2017 +0000 @@ -23,9 +23,9 @@ #define PI_F (3.1415926f) -#define MCP3008_SPI_SPEED (1000000) +#define MCP3008_SPI_SPEED (1312500) #define AD8402_SPI_SPEED (10000000) -#define ENVELOPE_UPDATE_RATE (32000) // Hz +#define ENVELOPE_UPDATE_RATE (8000) // Hz #define AD8402_RMAX (10000.0f) #define AD8402_RMIN (50.0f) @@ -58,13 +58,16 @@ EnvelopeAR envelopeFrequency(5, 300, 880.0f, 120.0f, 40.0f, 0.36f, 0.1f); EnvelopeAR envelopeAmplitude(50, 200, 0.99f, 1.0f, 0.0f); +EnvelopeAR envelopeNoiseAmplitude(50, 200, 0.99f, 1.0f, 0.0f); EnvelopeParam frequencyParam; EnvelopeParam amplitudeParam; +EnvelopeParam noiseAmplitudeParam; volatile int ticks; volatile float frequency; volatile float amplitude; +volatile float noiseAmplitude; volatile float bpm; volatile int envelopeLength; @@ -170,6 +173,14 @@ frequencyParam.v2 = AvgAdc2.read_input(6) * 400.0f; frequencyParam.attackTauRatio = AvgAdc2.read_input(2) + 0.01f; frequencyParam.releaseTauRatio = AvgAdc2.read_input(3) + 0.01f; + + noiseAmplitudeParam.attack = AvgAdc3.read_input(0) * envelopeLength; + noiseAmplitudeParam.release = AvgAdc3.read_input(1) * envelopeLength; + noiseAmplitudeParam.v0 = AvgAdc3.read_input(4); + noiseAmplitudeParam.v1 = AvgAdc3.read_input(5); + noiseAmplitudeParam.v2 = AvgAdc3.read_input(6); + noiseAmplitudeParam.attackTauRatio = AvgAdc3.read_input(2) + 0.01f; + noiseAmplitudeParam.releaseTauRatio = AvgAdc3.read_input(3) + 0.01f; } int main() @@ -186,6 +197,7 @@ frequency = 100.0f; amplitude = 1.0f; + noiseAmplitude = 1.0f; bpm = 120.0f; readParams(); @@ -214,7 +226,11 @@ printf("%d\t%d\t", frequencyParam.attack, frequencyParam.release); printf("%.2f\t%.2f\t%.2f\t", frequencyParam.v0, frequencyParam.v1, frequencyParam.v2); - printf("%.2f\t%.2f\r\n", frequencyParam.attackTauRatio, frequencyParam.releaseTauRatio); + printf("%.2f\t%.2f\t", frequencyParam.attackTauRatio, frequencyParam.releaseTauRatio); + + printf("%d\t%d\t", noiseAmplitudeParam.attack, noiseAmplitudeParam.release); + printf("%.2f\t%.2f\t%.2f\t", noiseAmplitudeParam.v0, noiseAmplitudeParam.v1, noiseAmplitudeParam.v2); + printf("%.2f\t%.2f\r\n", noiseAmplitudeParam.attackTauRatio, noiseAmplitudeParam.releaseTauRatio); #endif Thread::wait(1);