mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-25 16:31:42 +00:00
Since input and output are floating point, using an integer Stepper is not appropriate.
This commit is contained in:
parent
22c9734874
commit
f783ec6269
@ -10,7 +10,6 @@
|
|||||||
#define FilteringSpeaker_h
|
#define FilteringSpeaker_h
|
||||||
|
|
||||||
#include "../Speaker.hpp"
|
#include "../Speaker.hpp"
|
||||||
#include "../../../SignalProcessing/Stepper.hpp"
|
|
||||||
#include "../../../SignalProcessing/FIRFilter.hpp"
|
#include "../../../SignalProcessing/FIRFilter.hpp"
|
||||||
#include "../../../ClockReceiver/ClockReceiver.hpp"
|
#include "../../../ClockReceiver/ClockReceiver.hpp"
|
||||||
#include "../../../Concurrency/AsyncTaskQueue.hpp"
|
#include "../../../Concurrency/AsyncTaskQueue.hpp"
|
||||||
@ -198,7 +197,8 @@ template <typename SampleSource> class LowpassSpeaker: public Speaker {
|
|||||||
std::vector<int16_t> input_buffer_;
|
std::vector<int16_t> input_buffer_;
|
||||||
std::vector<int16_t> output_buffer_;
|
std::vector<int16_t> output_buffer_;
|
||||||
|
|
||||||
std::unique_ptr<SignalProcessing::Stepper> stepper_;
|
float step_rate_ = 0.0f;
|
||||||
|
float position_error_ = 0.0f;
|
||||||
std::unique_ptr<SignalProcessing::FIRFilter> filter_;
|
std::unique_ptr<SignalProcessing::FIRFilter> filter_;
|
||||||
|
|
||||||
std::mutex filter_parameters_mutex_;
|
std::mutex filter_parameters_mutex_;
|
||||||
@ -223,9 +223,8 @@ template <typename SampleSource> class LowpassSpeaker: public Speaker {
|
|||||||
);
|
);
|
||||||
number_of_taps = (number_of_taps * 2) | 1;
|
number_of_taps = (number_of_taps * 2) | 1;
|
||||||
|
|
||||||
stepper_ = std::make_unique<SignalProcessing::Stepper>(
|
step_rate_ = filter_parameters.input_cycles_per_second / filter_parameters.output_cycles_per_second;
|
||||||
uint64_t(filter_parameters.input_cycles_per_second),
|
position_error_ = 0.0f;
|
||||||
uint64_t(filter_parameters.output_cycles_per_second));
|
|
||||||
|
|
||||||
filter_ = std::make_unique<SignalProcessing::FIRFilter>(
|
filter_ = std::make_unique<SignalProcessing::FIRFilter>(
|
||||||
unsigned(number_of_taps),
|
unsigned(number_of_taps),
|
||||||
@ -304,7 +303,8 @@ template <typename SampleSource> class LowpassSpeaker: public Speaker {
|
|||||||
// If the next loop around is going to reuse some of the samples just collected, use a memmove to
|
// If the next loop around is going to reuse some of the samples just collected, use a memmove to
|
||||||
// preserve them in the correct locations (TODO: use a longer buffer to fix that?) and don't skip
|
// preserve them in the correct locations (TODO: use a longer buffer to fix that?) and don't skip
|
||||||
// anything. Otherwise skip as required to get to the next sample batch and don't expect to reuse.
|
// anything. Otherwise skip as required to get to the next sample batch and don't expect to reuse.
|
||||||
const auto steps = stepper_->step() * (SampleSource::get_is_stereo() ? 2 : 1);
|
const size_t steps = size_t(step_rate_ + position_error_) * (SampleSource::get_is_stereo() ? 2 : 1);
|
||||||
|
position_error_ = fmodf(step_rate_ + position_error_, 1.0f);
|
||||||
if(steps < input_buffer_.size()) {
|
if(steps < input_buffer_.size()) {
|
||||||
auto *const input_buffer = input_buffer_.data();
|
auto *const input_buffer = input_buffer_.data();
|
||||||
std::memmove( input_buffer,
|
std::memmove( input_buffer,
|
||||||
|
Loading…
Reference in New Issue
Block a user