KIK 01 Prototype 05
Dependencies: AverageMCP3008 mbed-rtos mbed mcp3008
Fork of KIK01_Proto03 by
Diff: main.cpp
- Revision:
- 6:897d6392b408
- Parent:
- 5:846772a77d33
- Child:
- 7:6735a343780e
--- a/main.cpp Sun Jun 04 08:59:53 2017 +0000 +++ b/main.cpp Sun Jun 04 09:32:30 2017 +0000 @@ -16,8 +16,8 @@ #define SAMPLING_RATE (48000) #define SAMPLING_PERIOD (1.0f/SAMPLING_RATE) -#define FREQUENCY_ATTACK (5) -#define FREQUENCY_RELEASE (300) +//#define FREQUENCY_ATTACK (5) +//#define FREQUENCY_RELEASE (300) //#define AMPLITUDE_ATTACK (50) //#define AMPLITUDE_RELEASE (200) @@ -123,7 +123,7 @@ }; EnvelopeAR envelopeFrequency( - FREQUENCY_ATTACK, FREQUENCY_RELEASE, 880.0f, 120.0f, 40.0f, 0.36f, 0.1f); + 5, 300, 880.0f, 120.0f, 40.0f, 0.36f, 0.1f); EnvelopeAR envelopeAmplitude(50, 200, 0.99f, 1.0f, 0.0f); volatile EnvelopeParam frequencyParam; @@ -182,7 +182,13 @@ envelopeAmplitude.setAttackTauRatio(amplitudeParam.attackTauRatio); envelopeAmplitude.setReleaseTauRatio(amplitudeParam.releaseTauRatio); + envelopeFrequency.setAttack(frequencyParam.attack); + envelopeFrequency.setRelease(frequencyParam.release); envelopeFrequency.setV0(frequencyParam.v0); + envelopeFrequency.setV1(frequencyParam.v1); + envelopeFrequency.setV2(frequencyParam.v2); + envelopeFrequency.setAttackTauRatio(frequencyParam.attackTauRatio); + envelopeFrequency.setReleaseTauRatio(frequencyParam.releaseTauRatio); generateEnvelope(); } @@ -199,10 +205,15 @@ amplitudeParam.v1 = 1.0f; amplitudeParam.v2 = 0.0f; amplitudeParam.attackTauRatio = 0.36f; - amplitudeParam.releaseTauRatio = 0.36f; + amplitudeParam.releaseTauRatio = Ain4.read(); - frequencyParam.v0 = Ain5.read() * 3000.0f + 50.0f; - frequencyParam.v1 = frequencyParam.v0; + frequencyParam.attack = 5; + frequencyParam.release = 300; + frequencyParam.v0 = Ain5.read() * 4000.0f; + frequencyParam.v1 = Ain6.read() * 400.0f; + frequencyParam.v2 = Ain7.read() * 400.0f; + frequencyParam.attackTauRatio = 0.36f; + frequencyParam.releaseTauRatio = 0.1f; } int main() @@ -224,12 +235,16 @@ for (;;) { setParams(); - printf("%.1f\t%d\t%d\t%.1f\r\n", - bpm, - envelopeLength, - amplitudeParam.attack, - frequencyParam.v0 - ); + printf("%.1f\t%d\t", bpm, envelopeLength); + + printf("%d\t%d\t", amplitudeParam.attack, amplitudeParam.release); + printf("%.2f\t%.2f\t%.2f\t", amplitudeParam.v0, amplitudeParam.v1, amplitudeParam.v2); + printf("%.2f\t%.2f\t", amplitudeParam.attackTauRatio, amplitudeParam.releaseTauRatio); + + 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); + Thread::wait(500); } }