commit 5a96dabd5658664b3a819a245cfa358db8edc3c9
parent 9939c1c7b70cdd848bdd7e8365531d5d0796e384
Author: Matt Demanett <matt@demanett.net>
Date: Sat, 30 Dec 2017 23:17:39 -0500
Use PulseGenerator for end-of-cycle triggers and with Manual.
Diffstat:
5 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/DADSRHCore.cpp b/src/DADSRHCore.cpp
@@ -4,6 +4,7 @@
void DADSRHCore::reset() {
_trigger.reset();
+ _triggerOuptutPulseGen.process(10.0);
_stage = STOPPED_STAGE;
_releaseLevel = _holdProgress = _stageProgress = _envelope = 0.0;
}
@@ -185,7 +186,7 @@ void DADSRHCore::step() {
if (_envelope <= 0.001) {
complete = true;
_envelope = 0.0;
- if (_loopParam.value <= 0.5) {
+ if (_modeParam.value < 0.5 && _loopParam.value <= 0.5) {
_stage = DELAY_STAGE;
_holdProgress = _stageProgress = 0.0;
}
@@ -200,7 +201,11 @@ void DADSRHCore::step() {
float env = _envelope * 10.0;
_envOutput.value = env;
_invOutput.value = 10.0 - env;
- _triggerOutput.value = complete ? 5.0 : 0.0;
+
+ if (complete) {
+ _triggerOuptutPulseGen.trigger(0.001);
+ }
+ _triggerOutput.value = _triggerOuptutPulseGen.process(engineGetSampleTime()) ? 5.0 : 0.0;
if (_delayOutput) {
_delayOutput->value = _stage == DELAY_STAGE ? 5.0 : 0.0;
diff --git a/src/DADSRHCore.hpp b/src/DADSRHCore.hpp
@@ -60,6 +60,7 @@ struct DADSRHCore {
Light& _releaseShape3Light;
SchmittTrigger _trigger;
+ PulseGenerator _triggerOuptutPulseGen;
Stage _stage;
float _envelope, _stageProgress, _holdProgress, _releaseLevel;
diff --git a/src/Manual.cpp b/src/Manual.cpp
@@ -29,6 +29,7 @@ struct Manual : Module {
};
SchmittTrigger _trigger;
+ PulseGenerator _pulse;
Manual() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
reset();
@@ -40,10 +41,19 @@ struct Manual : Module {
void Manual::reset() {
_trigger.reset();
+ _pulse.process(10.0);
}
void Manual::step() {
bool high = _trigger.process(params[TRIGGER_PARAM].value) || _trigger.isHigh();
+ if (high) {
+ _pulse.trigger(0.001);
+ _pulse.process(engineGetSampleTime());
+ }
+ else {
+ high = _pulse.process(engineGetSampleTime());
+ }
+
float out = high ? 5.0 : 0.0;
outputs[OUT1_OUTPUT].value = out;
outputs[OUT2_OUTPUT].value = out;
diff --git a/src/ShaperCore.cpp b/src/ShaperCore.cpp
@@ -4,6 +4,7 @@
void ShaperCore::reset() {
_trigger.reset();
+ _triggerOuptutPulseGen.process(10.0);
_stage = STOPPED_STAGE;
_stageProgress = 0.0;
}
@@ -86,7 +87,11 @@ void ShaperCore::step() {
float envOutput = clampf(envLevel * envelope, 0.0, 10.0);
_envOutput.value = envOutput;
_invOutput.value = 10.0 - envOutput;
- _triggerOutput.value = complete ? 5.0 : 0.0;
+
+ if (complete) {
+ _triggerOuptutPulseGen.trigger(0.001);
+ }
+ _triggerOutput.value = _triggerOuptutPulseGen.process(engineGetSampleTime()) ? 5.0 : 0.0;
if (_attackOutput) {
_attackOutput->value = _stage == ATTACK_STAGE ? 5.0 : 0.0;
diff --git a/src/ShaperCore.hpp b/src/ShaperCore.hpp
@@ -44,6 +44,7 @@ struct ShaperCore {
Light& _offLight;
SchmittTrigger _trigger;
+ PulseGenerator _triggerOuptutPulseGen;
Stage _stage;
float _stageProgress;