BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit aa735b5599ca16413051ad1142e426c2acd986d0
parent a9a6c7f8ef802eb3a0547154f8d264622de8da98
Author: Matt Demanett <matt@demanett.net>
Date:   Sun, 17 Nov 2019 17:19:24 -0500

MANUAL: delay "loadbang" pulse for 100ms after the patch starts running, to possibly avoid problems with modules initializing.

Diffstat:
MREADME.md | 2+-
Msrc/Manual.cpp | 11++++++++---
Msrc/Manual.hpp | 8+++++++-
3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md @@ -574,7 +574,7 @@ _Polyphony:_ <a href="#polyphony">Polyphonic</a>, with polyphony defined by the A manual trigger/gate with 8 outputs. A constant high value is sent from each output for as long as the TRIG button is held. -Manual may be set to output a trigger pulse on patch load (akin to a Max/Msp loadbang). This is off by default; enable clicking "Trigger on Load" on the module's context (right-click) menu. +Manual may be set to output a trigger pulse (+5V for 10ms) on patch load (akin to a Max/Msp loadbang). This is off by default; enable clicking "Trigger on Load" on the module's context (right-click) menu. [New in version 1.1.24:] The pulse is emitted 100ms after the patch starts processing samples. _Polyphony:_ Monophonic. diff --git a/src/Manual.cpp b/src/Manual.cpp @@ -7,7 +7,14 @@ void Manual::reset() { } void Manual::processChannel(const ProcessArgs& args, int _c) { - bool high = _trigger.process(params[TRIGGER_PARAM].getValue()) || _trigger.isHigh() || (_firstStep && _triggerOnLoad && _shouldTriggerOnLoad); + bool initialPulse = false; + if (_initialDelay && !_initialDelay->next()) { + initialPulse = true; + delete _initialDelay; + _initialDelay = NULL; + } + + bool high = _trigger.process(params[TRIGGER_PARAM].getValue()) || _trigger.isHigh() || (initialPulse && _triggerOnLoad && _shouldTriggerOnLoad); if (high) { _pulse.trigger(0.001f); _pulse.process(APP->engine->getSampleTime()); @@ -25,8 +32,6 @@ void Manual::processChannel(const ProcessArgs& args, int _c) { outputs[OUT6_OUTPUT].setVoltage(out); outputs[OUT7_OUTPUT].setVoltage(out); outputs[OUT8_OUTPUT].setVoltage(out); - - _firstStep = false; } struct ManualWidget : TriggerOnLoadModuleWidget { diff --git a/src/Manual.hpp b/src/Manual.hpp @@ -33,16 +33,22 @@ struct Manual : TriggerOnLoadModule { NUM_LIGHTS }; - bool _firstStep = true; Trigger _trigger; rack::dsp::PulseGenerator _pulse; + bogaudio::dsp::Timer* _initialDelay = NULL; Manual() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); configParam(TRIGGER_PARAM, 0.0f, 1.0f, 0.0f, "Trigger"); _triggerOnLoad = false; + _initialDelay = new bogaudio::dsp::Timer(APP->engine->getSampleRate(), 0.01f); reset(); } + virtual ~Manual() { + if (_initialDelay) { + delete _initialDelay; + } + } void reset() override; void processChannel(const ProcessArgs& args, int _c) override;