KIK 01 Prototype 05
Dependencies: AverageMCP3008 mbed-rtos mbed mcp3008
Fork of KIK01_Proto03 by
Diff: main.cpp
- Revision:
- 23:da7c5f7feff1
- Parent:
- 22:a3bb7594f9bb
- Child:
- 24:e9fbadd15e90
--- a/main.cpp Sun Sep 17 19:11:41 2017 +0000 +++ b/main.cpp Sun Sep 17 23:24:49 2017 +0000 @@ -23,7 +23,7 @@ #define MCP3008_SPI_SPEED (1000000) #define AD8402_SPI_SPEED (10000000) -#define ENVELOPE_UPDATE_RATE (20000) // Hz +#define ENVELOPE_UPDATE_RATE (32000) // Hz #define AD8402_RMAX (10000.0f) #define AD8402_RMIN (50.0f) @@ -78,10 +78,8 @@ #endif } -void DcoSetFrequency() +void DcoSetFrequency(float freq) { - frequency = envelopeFrequency.getAmplitude(ticks); - const float c = 0.00000047; float r = 1.0f / (2.0f * PI_F * frequency * c); if (r < AD8402_RMIN) r = AD8402_RMIN; @@ -91,7 +89,11 @@ AD8402Write(0, v); AD8402Write(1, v); +} +void DcaSetAmplitude(float amp) +{ + Dac1.write(amp); } void update() @@ -122,7 +124,11 @@ envelopeFrequency.setAttackTauRatio(frequencyParam.attackTauRatio); envelopeFrequency.setReleaseTauRatio(frequencyParam.releaseTauRatio); - DcoSetFrequency(); + frequency = envelopeFrequency.getAmplitude(ticks); + amplitude = envelopeAmplitude.getAmplitude(ticks); + + DcoSetFrequency(frequency); + DcaSetAmplitude(amplitude); ticks++; if (ticks >= envelopeLength) {