KIK 01 Prototype 05
Dependencies: AverageMCP3008 mbed-rtos mbed mcp3008
Fork of KIK01_Proto03 by
Diff: main.cpp
- Revision:
- 4:9f53a82fc1b6
- Parent:
- 3:f89b400cfe57
- Child:
- 5:846772a77d33
--- a/main.cpp Sun Jun 04 06:25:48 2017 +0000 +++ b/main.cpp Sun Jun 04 07:49:50 2017 +0000 @@ -18,12 +18,14 @@ #define FREQUENCY_ATTACK (5) #define FREQUENCY_RELEASE (300) -#define AMPLITUDE_ATTACK (50) +//#define AMPLITUDE_ATTACK (50) #define AMPLITUDE_RELEASE (200) AnalogOut Dac1(PA_5); AnalogIn AinBpm(PA_0); +AnalogIn AinAmplitudeAttack(PA_1); +AnalogIn AinFrequencyF0(PA_4); class EnvelopeAR { public: @@ -97,7 +99,7 @@ EnvelopeAR envelopeFrequency( FREQUENCY_ATTACK, FREQUENCY_RELEASE, 880.0f, 120.0f, 40.0f, 0.36f, 0.1f); -EnvelopeAR envelopeAmplitude(AMPLITUDE_ATTACK, AMPLITUDE_RELEASE, 0.9f, 1.0f, 0.0f); +EnvelopeAR envelopeAmplitude(50, AMPLITUDE_RELEASE, 0.95f, 1.0f, 0.0f); volatile int ticks; volatile int envelopeTicks; @@ -108,6 +110,8 @@ float bpm; int envelopeLength; +int amplitudeAttack; +float frequencyF0; void generateWave() { @@ -161,9 +165,15 @@ bpm = 120.0f; for (;;) { - bpm = AinBpm.read() * 120.0f + 60.0f; + bpm = AinBpm.read() * 180.0f + 60.0f; envelopeLength = 60 * 1000 / bpm; - printf("%f\t%d\r\n", bpm, envelopeLength); - Thread::wait(100); + amplitudeAttack = AinAmplitudeAttack.read() * envelopeLength * 0.7f; + envelopeAmplitude.setAttack(amplitudeAttack); + frequencyF0 = AinFrequencyF0.read() * 2000.0f + 50.0f; + envelopeFrequency.setV0(frequencyF0); + + printf("%f\t%d\t%d\t%f\r\n", bpm, envelopeLength, amplitudeAttack, frequencyF0); + + Thread::wait(500); } }