Skip to content

Commit

Permalink
fix trigger inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kautenja committed Jan 13, 2021
1 parent 061d9f1 commit 16a5acb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/PalletTownWavesSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
struct PalletTownWavesSystem : ChipModule<NintendoGBS> {
private:
/// a Trigger for handling inputs to the LFSR port
Trigger::Boolean lfsr[PORT_MAX_CHANNELS];
Trigger::Threshold lfsr[PORT_MAX_CHANNELS];

public:
/// the indexes of parameters (knobs, switches, etc.) on the module
Expand Down Expand Up @@ -320,7 +320,7 @@ struct PalletTownWavesSystem : ChipModule<NintendoGBS> {
/// @param channel the polyphonic channel to process the CV inputs to
///
inline void processCV(const ProcessArgs &args, unsigned channel) final {
lfsr[channel].process(rescale(inputs[INPUT_LFSR].getVoltage(channel), 0.f, 2.f, 0.f, 1.f));
lfsr[channel].process(rescale(inputs[INPUT_LFSR].getVoltage(channel), 0.01f, 2.f, 0.f, 1.f));
// turn on the power
apu[channel].write(NintendoGBS::POWER_CONTROL_STATUS, 0b10000000);
// set the global volume
Expand Down
8 changes: 4 additions & 4 deletions src/SuperADSR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ struct SuperADSR : Module {
/// the Sony S-DSP ADSR enveloper generator emulator
SonyS_DSP::ADSR apus[LANES][PORT_MAX_CHANNELS];
/// triggers for handling input trigger and gate signals
Trigger::Boolean gateTrigger[LANES][PORT_MAX_CHANNELS];
Trigger::Threshold gateTrigger[LANES][PORT_MAX_CHANNELS];
/// triggers for handling input re-trigger signals
Trigger::Boolean retrigTrigger[LANES][PORT_MAX_CHANNELS];
Trigger::Threshold retrigTrigger[LANES][PORT_MAX_CHANNELS];
/// a clock divider for light updates
Trigger::Divider lightDivider;

Expand Down Expand Up @@ -95,10 +95,10 @@ struct SuperADSR : Module {
///
inline bool getTrigger(unsigned channel, unsigned lane) {
// get the trigger from the gate input
const auto gateCV = rescale(inputs[INPUT_GATE + lane].getVoltage(channel), 0.f, 2.f, 0.f, 1.f);
const auto gateCV = rescale(inputs[INPUT_GATE + lane].getVoltage(channel), 0.01f, 2.f, 0.f, 1.f);
const bool gate = gateTrigger[lane][channel].process(gateCV);
// get the trigger from the re-trigger input
const auto retrigCV = rescale(inputs[INPUT_RETRIG + lane].getVoltage(channel), 0.f, 2.f, 0.f, 1.f);
const auto retrigCV = rescale(inputs[INPUT_RETRIG + lane].getVoltage(channel), 0.01f, 2.f, 0.f, 1.f);
const bool retrig = retrigTrigger[lane][channel].process(retrigCV);
// OR the two boolean values together
return gate || retrig;
Expand Down
8 changes: 4 additions & 4 deletions src/SuperSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ struct SuperSampler : Module {
/// the Sony S-DSP sound chip emulator
SonyS_DSP::BRR_SamplePlayer apu[NUM_VOICES][PORT_MAX_CHANNELS];
/// triggers for handling gate inputs for the voices
Trigger::Boolean gateTriggers[NUM_VOICES][PORT_MAX_CHANNELS];
Trigger::Threshold gateTriggers[NUM_VOICES][PORT_MAX_CHANNELS];
/// triggers for handling inputs to the phase modulation enable ports
Trigger::Boolean pmTriggers[NUM_VOICES][PORT_MAX_CHANNELS];
Trigger::Threshold pmTriggers[NUM_VOICES][PORT_MAX_CHANNELS];

public:
/// the indexes of parameters (knobs, switches, etc.) on the module
Expand Down Expand Up @@ -162,13 +162,13 @@ struct SuperSampler : Module {
// MARK: Gate input
// -------------------------------------------------------------------
const auto gate = inputs[INPUT_GATE + voice].getVoltage(channel);
bool trigger = gateTriggers[voice][channel].process(rescale(gate, 0.f, 2.f, 0.f, 1.f));
bool trigger = gateTriggers[voice][channel].process(rescale(gate, 0.01f, 2.f, 0.f, 1.f));
// -------------------------------------------------------------------
// MARK: Stereo output
// -------------------------------------------------------------------
SonyS_DSP::StereoSample output;
// get a flag determining whether phase modulation is enabled for the voice
pmTriggers[voice][channel].process(rescale(inputs[INPUT_PM_ENABLE + voice].getVoltage(channel), 0.f, 2.f, 0.f, 1.f));
pmTriggers[voice][channel].process(rescale(inputs[INPUT_PM_ENABLE + voice].getVoltage(channel), 0.01f, 2.f, 0.f, 1.f));
bool is_pm = (1 - params[PARAM_PM_ENABLE + voice].getValue()) - !pmTriggers[voice][channel].isHigh();
// run the sample through the voice
apu[voice][channel].run(
Expand Down
6 changes: 3 additions & 3 deletions src/SuperSynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct SuperSynth : Module {
inline void clearRAM() { memset(ram, 0, sizeof ram); }

/// triggers for handling gate inputs for the voices
Trigger::Boolean gateTriggers[SonyS_DSP::Processor::VOICE_COUNT][2];
Trigger::Threshold gateTriggers[SonyS_DSP::Processor::VOICE_COUNT][2];

public:
/// the indexes of parameters (knobs, switches, etc.) on the module
Expand Down Expand Up @@ -239,9 +239,9 @@ struct SuperSynth : Module {
// get the voltage from the gate input port
const auto gate = inputs[INPUT_GATE + voice].getVoltage();
// process the voltage to detect key-on events
key_on = key_on | (gateTriggers[voice][0].process(rescale(gate, 0.f, 2.f, 0.f, 1.f)) << voice);
key_on = key_on | (gateTriggers[voice][0].process(rescale(gate, 0.01f, 2.f, 0.f, 1.f)) << voice);
// process the inverted voltage to detect key-of events
key_off = key_off | (gateTriggers[voice][1].process(rescale(10.f - gate, 0.f, 2.f, 0.f, 1.f)) << voice);
key_off = key_off | (gateTriggers[voice][1].process(rescale(10.f - gate, 0.01f, 2.f, 0.f, 1.f)) << voice);
}
if (key_on) { // a key-on event occurred from the gate input
// write key off to enable all voices
Expand Down

0 comments on commit 16a5acb

Please sign in to comment.