KIK01 Release
Dependencies: mcp3008 mbed mbed-rtos AverageMCP3008 VoltageMonitor
Revision 43:e5e2d1761156, committed 2019-03-01
- Comitter:
- ryood
- Date:
- Fri Mar 01 01:02:38 2019 +0000
- Parent:
- 42:f58bae8771fe
- Commit message:
- EnvelopeAR: Range check (attack, release)
Changed in this revision
EnvelopeAR.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f58bae8771fe -r e5e2d1761156 EnvelopeAR.h --- a/EnvelopeAR.h Fri Mar 01 00:57:06 2019 +0000 +++ b/EnvelopeAR.h Fri Mar 01 01:02:38 2019 +0000 @@ -50,7 +50,11 @@ ~EnvelopeAR() {} void setAttack(int _attack) { - attack = _attack; + if (_attack > 0) { + attack = _attack; + } else { + attack = 1; + } tau0 = attack * attackTauRatio; } int getAttack() { @@ -58,7 +62,11 @@ } void setRelease(int _release) { - release = _release; + if (_release > 0) { + release = _release; + } else { + release = 1; + } tau1 = release * releaseTauRatio; } int getRelease() {
diff -r f58bae8771fe -r e5e2d1761156 main.cpp --- a/main.cpp Fri Mar 01 00:57:06 2019 +0000 +++ b/main.cpp Fri Mar 01 01:02:38 2019 +0000 @@ -292,7 +292,7 @@ envelopeLength = 60 * ENVELOPE_UPDATE_RATE / bpm; stepLength = envelopeLength / 4; - amplitudeParamKik.attack = AvgAdc1.read_input(0) * envelopeLength + 1; + amplitudeParamKik.attack = AvgAdc1.read_input(0) * envelopeLength; amplitudeParamKik.release = AvgAdc1.read_input(1) * envelopeLength; amplitudeParamKik.v0 = AvgAdc1.read_input(4); amplitudeParamKik.v1 = AvgAdc1.read_input(5); @@ -301,14 +301,14 @@ amplitudeParamKik.releaseTauRatio = AvgAdc1.read_input(3) + 0.01f; frequencyParamKik.attack = AvgAdc2.read_input(0) * envelopeLength * 0.1f; - frequencyParamKik.release = AvgAdc2.read_input(1) * envelopeLength + 1; + frequencyParamKik.release = AvgAdc2.read_input(1) * envelopeLength; frequencyParamKik.v0 = AvgAdc2.read_input(4) * 4000.0f; frequencyParamKik.v1 = AvgAdc2.read_input(5) * 400.0f; frequencyParamKik.v2 = AvgAdc2.read_input(6) * 400.0f; frequencyParamKik.attackTauRatio = AvgAdc2.read_input(2) + 0.01f; frequencyParamKik.releaseTauRatio = AvgAdc2.read_input(3) + 0.01f; - amplitudeParamNos.attack = AvgAdc3.read_input(0) * envelopeLength + 1; + amplitudeParamNos.attack = AvgAdc3.read_input(0) * envelopeLength; amplitudeParamNos.release = AvgAdc3.read_input(1) * envelopeLength; amplitudeParamNos.v0 = AvgAdc3.read_input(4); amplitudeParamNos.v1 = AvgAdc3.read_input(5);