computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit c11345e67ef745cb5847764a5cc45ec3e8fcc704
parent d2bdd665810805d35e3d140b0861010c2aed788b
Author: Dort <aemalone@gmail.com>
Date:   Tue,  4 Jun 2024 10:44:22 -0500

check if input and output are connected before getting voltage/setting voltage to prevent crash

Diffstat:
Msrc/ComputerscareTolyPools-v2.cpp | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/ComputerscareTolyPools-v2.cpp b/src/ComputerscareTolyPools-v2.cpp @@ -108,9 +108,15 @@ struct ComputerscareTolyPoolsV2 : Module { } - - for (int i = 0; i < numOutputChannels; i++) { - outputs[POLY_OUTPUT].setVoltage(inputs[POLY_INPUT].getVoltage((i + rotation + rotationBase*16) % rotationBase), i); + if(inputs[POLY_INPUT].isConnected() && outputs[POLY_OUTPUT].isConnected()) { + for (int i = 0; i < numOutputChannels; i++) { + outputs[POLY_OUTPUT].setVoltage(inputs[POLY_INPUT].getVoltage((i + rotation + rotationBase*16) % rotationBase), i); + } + } else { + for (int i = 0; i < numOutputChannels; i++) { + outputs[POLY_OUTPUT].setVoltage(0.f, i); + } + } } }