1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-23 20:29:42 +00:00

Fixed one off-by-one error.

This commit is contained in:
Thomas Harte 2016-01-14 21:33:27 -05:00
parent 8bd04a6be4
commit 383b2be4c6
2 changed files with 12 additions and 16 deletions

View File

@ -495,18 +495,13 @@ void Machine::set_key_state(Key key, bool isPressed)
void Machine::Speaker::get_samples(unsigned int number_of_samples, int16_t *target)
{
// if(!_is_enabled)
// {
// *target = 0;
// }
// else
if(!_is_enabled)
{
*target = 0;
}
else
{
*target = _output_level;
_output_level++;
if(_output_level&64)
{
_output_level ^= (8192 | 64);
}
}
skip_samples(number_of_samples);
}
@ -519,18 +514,18 @@ void Machine::Speaker::skip_samples(unsigned int number_of_samples)
if(_counter > _divider)
{
_counter = 0;
// _output_level ^= 8192;
_output_level ^= 8192;
}
}
}
void Machine::Speaker::set_divider(uint8_t divider)
{
// _divider = divider;
// _time_base = 0;
_divider = divider;
}
void Machine::Speaker::set_is_enabled(bool is_enabled)
{
// _is_enabled = is_enabled;
_is_enabled = is_enabled;
_counter = 0;
}

View File

@ -81,7 +81,6 @@ template <class T> class Filter: public Speaker {
{
// get a sample for the current location
static_cast<T *>(this)->get_samples(1, &_buffer_in_progress[_buffer_in_progress_pointer]);
// _buffer_in_progress[_buffer_in_progress_pointer] = (_buffer_in_progress_pointer&64) ? 8192 : 0;
_buffer_in_progress_pointer++;
// announce to delegate if full
@ -95,7 +94,9 @@ template <class T> class Filter: public Speaker {
}
// determine how many source samples to step
static_cast<T *>(this)->skip_samples((unsigned int)_stepper->update());
uint64_t steps = _stepper->update();
if(steps > 1)
static_cast<T *>(this)->skip_samples((unsigned int)(steps-1));
}
}