mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Number of taps can be specified explicitly if you desire.
This commit is contained in:
parent
499f7ace07
commit
5980f5e991
@ -35,11 +35,11 @@ class Speaker {
|
||||
set_needs_updated_filter_coefficients();
|
||||
}
|
||||
|
||||
// void set_output_quality(int number_of_taps)
|
||||
// {
|
||||
// _number_of_taps = number_of_taps;
|
||||
// set_needs_updated_filter_coefficients();
|
||||
// }
|
||||
void set_output_quality(int number_of_taps)
|
||||
{
|
||||
_requested_number_of_taps = number_of_taps;
|
||||
set_needs_updated_filter_coefficients();
|
||||
}
|
||||
|
||||
void set_delegate(Delegate *delegate)
|
||||
{
|
||||
@ -52,13 +52,13 @@ class Speaker {
|
||||
set_needs_updated_filter_coefficients();
|
||||
}
|
||||
|
||||
Speaker() : _buffer_in_progress_pointer(0) {}
|
||||
Speaker() : _buffer_in_progress_pointer(0), _requested_number_of_taps(0) {}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<int16_t> _buffer_in_progress;
|
||||
int _buffer_size;
|
||||
int _buffer_in_progress_pointer;
|
||||
int _number_of_taps;
|
||||
int _number_of_taps, _requested_number_of_taps;
|
||||
bool _coefficients_are_dirty;
|
||||
Delegate *_delegate;
|
||||
|
||||
@ -130,10 +130,17 @@ template <class T> class Filter: public Speaker {
|
||||
|
||||
void update_filter_coefficients()
|
||||
{
|
||||
// make a guess at a good number of taps
|
||||
_number_of_taps = (_input_cycles_per_second + _output_cycles_per_second) / _output_cycles_per_second;
|
||||
_number_of_taps *= 2;
|
||||
_number_of_taps |= 1;
|
||||
// make a guess at a good number of taps if this hasn't been provided explicitly
|
||||
if(_requested_number_of_taps)
|
||||
{
|
||||
_number_of_taps = _requested_number_of_taps;
|
||||
}
|
||||
else
|
||||
{
|
||||
_number_of_taps = (_input_cycles_per_second + _output_cycles_per_second) / _output_cycles_per_second;
|
||||
_number_of_taps *= 2;
|
||||
_number_of_taps |= 1;
|
||||
}
|
||||
|
||||
_coefficients_are_dirty = false;
|
||||
_buffer_in_progress_pointer = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user