mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-19 08:31:11 +00:00
Ensures artificial frequency limits are honoured.
This commit is contained in:
parent
60cf6b3cfd
commit
dbe3c5c3f8
@ -204,22 +204,22 @@ template <typename T> class LowpassSpeaker: public Speaker {
|
|||||||
} filter_parameters_;
|
} filter_parameters_;
|
||||||
|
|
||||||
void update_filter_coefficients(const FilterParameters &filter_parameters) {
|
void update_filter_coefficients(const FilterParameters &filter_parameters) {
|
||||||
|
float high_pass_frequency = filter_parameters.output_cycles_per_second / 2.0f;
|
||||||
|
if(filter_parameters.high_frequency_cutoff > 0.0) {
|
||||||
|
high_pass_frequency = std::min(filter_parameters.high_frequency_cutoff, high_pass_frequency);
|
||||||
|
}
|
||||||
|
|
||||||
// Make a guess at a good number of taps.
|
// Make a guess at a good number of taps.
|
||||||
std::size_t number_of_taps = static_cast<std::size_t>(
|
std::size_t number_of_taps = static_cast<std::size_t>(
|
||||||
ceilf((filter_parameters.input_cycles_per_second + filter_parameters.output_cycles_per_second) / filter_parameters.output_cycles_per_second)
|
ceilf((filter_parameters.input_cycles_per_second + high_pass_frequency) / high_pass_frequency)
|
||||||
);
|
);
|
||||||
number_of_taps = (number_of_taps * 2) | 1;
|
number_of_taps = (number_of_taps * 2) | 1;
|
||||||
|
|
||||||
output_buffer_pointer_ = 0;
|
output_buffer_pointer_ = 0;
|
||||||
|
|
||||||
stepper_.reset(new SignalProcessing::Stepper(
|
stepper_.reset(new SignalProcessing::Stepper(
|
||||||
static_cast<uint64_t>(filter_parameters.input_cycles_per_second),
|
static_cast<uint64_t>(filter_parameters.input_cycles_per_second),
|
||||||
static_cast<uint64_t>(filter_parameters.output_cycles_per_second)));
|
static_cast<uint64_t>(filter_parameters.output_cycles_per_second)));
|
||||||
|
|
||||||
float high_pass_frequency = filter_parameters.output_cycles_per_second / 2.0f;
|
|
||||||
if(filter_parameters.high_frequency_cutoff > 0.0) {
|
|
||||||
high_pass_frequency = std::min(filter_parameters.output_cycles_per_second / 2.0f, high_pass_frequency);
|
|
||||||
}
|
|
||||||
filter_.reset(new SignalProcessing::FIRFilter(
|
filter_.reset(new SignalProcessing::FIRFilter(
|
||||||
static_cast<unsigned int>(number_of_taps),
|
static_cast<unsigned int>(number_of_taps),
|
||||||
filter_parameters.input_cycles_per_second,
|
filter_parameters.input_cycles_per_second,
|
||||||
|
Loading…
Reference in New Issue
Block a user