KIK01 Release
Dependencies: mcp3008 mbed mbed-rtos AverageMCP3008 VoltageMonitor
Diff: main.cpp
- Revision:
- 25:b4977c7e0db7
- Parent:
- 24:e9fbadd15e90
- Child:
- 26:866d672ba446
--- a/main.cpp Thu Sep 28 01:21:04 2017 +0000 +++ b/main.cpp Thu Sep 28 02:32:53 2017 +0000 @@ -17,7 +17,7 @@ #define UART_TRACE (1) #define PIN_CHECK (1) #define TITLE_STR1 ("KIK01 Kick Machine") -#define TITLE_STR2 ("20170916") +#define TITLE_STR2 ("20170928") #define PI_F (3.1415926f) @@ -50,8 +50,8 @@ EnvelopeAR envelopeFrequency(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; -volatile EnvelopeParam amplitudeParam; +EnvelopeParam frequencyParam; +EnvelopeParam amplitudeParam; volatile int ticks; volatile float frequency; @@ -108,21 +108,8 @@ } // set envelope parameters - envelopeAmplitude.setAttack(amplitudeParam.attack); - envelopeAmplitude.setRelease(amplitudeParam.release); - envelopeAmplitude.setV0(amplitudeParam.v0); - envelopeAmplitude.setV1(amplitudeParam.v1); - envelopeAmplitude.setV2(amplitudeParam.v2); - 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); + envelopeAmplitude.setParam(amplitudeParam); + envelopeFrequency.setParam(frequencyParam); frequency = envelopeFrequency.getAmplitude(ticks); amplitude = envelopeAmplitude.getAmplitude(ticks); @@ -143,7 +130,7 @@ #endif } -void setParams() +void readParams() { bpm = Adc0.read_input(7) * 180.0f + 60.0f; envelopeLength = 60 * ENVELOPE_UPDATE_RATE / bpm; @@ -180,7 +167,7 @@ amplitude = 1.0f; bpm = 120.0f; - setParams(); + readParams(); ticks = 0; Ticker samplingTicker; @@ -190,7 +177,9 @@ #if (PIN_CHECK) Dout2 = 1; #endif - setParams(); + + readParams(); + #if (PIN_CHECK) Dout2 = 0; #endif