From b58e59e2bbef31074bf54ad9c10453f0847c9ee0 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 14 Jan 2016 23:12:40 -0500 Subject: [PATCH] Fixed: now outputting the requested output rate, rather than massively overproducing at the input rate. --- Outputs/Speaker.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Outputs/Speaker.hpp b/Outputs/Speaker.hpp index 74f29975c..077b5014b 100644 --- a/Outputs/Speaker.hpp +++ b/Outputs/Speaker.hpp @@ -77,7 +77,8 @@ template class Filter: public Speaker { if(_coefficients_are_dirty) update_filter_coefficients(); // point sample for now, as a temporary measure - while(input_cycles--) + input_cycles += _input_cycles_carry; + while(input_cycles > 0) { // get a sample for the current location static_cast(this)->get_samples(1, &_buffer_in_progress[_buffer_in_progress_pointer]); @@ -97,11 +98,14 @@ template class Filter: public Speaker { uint64_t steps = _stepper->update(); if(steps > 1) static_cast(this)->skip_samples((unsigned int)(steps-1)); + input_cycles -= steps; } + _input_cycles_carry = input_cycles; } private: SignalProcessing::Stepper *_stepper; + int _input_cycles_carry; void update_filter_coefficients() {