From 614953a222a427ff93dd7086b70ac4ddee641386 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 2 Jul 2021 22:36:35 -0400 Subject: [PATCH] Allows the low-pass filter to react to high-pass effects. --- Machines/Enterprise/Dave.cpp | 20 +++++++++----------- Machines/Enterprise/Dave.hpp | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Machines/Enterprise/Dave.cpp b/Machines/Enterprise/Dave.cpp index 4f8f74ec8..474ee2940 100644 --- a/Machines/Enterprise/Dave.cpp +++ b/Machines/Enterprise/Dave.cpp @@ -124,6 +124,8 @@ void Audio::get_samples(std::size_t number_of_samples, int16_t *target) { } // Step 2: tick if necessary. + int noise_output = noise_.output & 1; + noise_.output <<= 1; if(noise_tick) { switch(noise_.polynomial) { case Noise::Polynomial::SeventeenBit: @@ -140,20 +142,16 @@ void Audio::get_samples(std::size_t number_of_samples, int16_t *target) { break; } - noise_.output <<= 1; - noise_.output |= poly_state_[int(Channel::Distortion::None)]; + noise_output = poly_state_[int(Channel::Distortion::None)]; + } + noise_.output |= noise_output; - // Low pass: sample channel 2 on downward transitions of the prima facie output. - if(noise_.low_pass) { - if((noise_.output & 3) == 2) { - noise_.output = (noise_.output & ~1) | (channels_[2].output & 1); - } else { - noise_.output = (noise_.output & ~1) | (noise_.output & 1); - } - } + // Low pass: sample channel 2 on downward transitions of the prima facie output. + if(noise_.low_pass && (noise_.output & 3) == 2) { + noise_.output = (noise_.output & ~1) | (channels_[2].output & 1); } - // Apply noise high-pass at the rate of the tone channels. + // Apply noise high-pass. if(noise_.high_pass && (channels_[0].output & 3) == 2) { noise_.output &= ~1; } diff --git a/Machines/Enterprise/Dave.hpp b/Machines/Enterprise/Dave.hpp index a280665af..fa867ccab 100644 --- a/Machines/Enterprise/Dave.hpp +++ b/Machines/Enterprise/Dave.hpp @@ -86,7 +86,7 @@ class Audio: public Outputs::Speaker::SampleSource { // Current state. int count = 0; - int output = false; + int output = 0; bool final_output = false; } noise_; void update_noise();