diff --git a/Machines/CRTMachine.hpp b/Machines/CRTMachine.hpp index c58f5d320..ce693f5cc 100644 --- a/Machines/CRTMachine.hpp +++ b/Machines/CRTMachine.hpp @@ -14,6 +14,11 @@ namespace CRTMachine { +/*! + A CRTMachine::Machine is a mostly-abstract base class for machines that connect to a CRT, + that optionally provide a speaker, and that nominate a clock rate and can announce to a delegate + should that clock rate change. +*/ class Machine { public: virtual void setup_output(float aspect_ratio) = 0; @@ -24,6 +29,7 @@ class Machine { virtual void run_for_cycles(int number_of_cycles) = 0; + // TODO: sever the clock-rate stuff. virtual double get_clock_rate() = 0; class Delegate { public: diff --git a/Outputs/Speaker.hpp b/Outputs/Speaker.hpp index 4bcf10408..41efa5586 100644 --- a/Outputs/Speaker.hpp +++ b/Outputs/Speaker.hpp @@ -17,6 +17,14 @@ namespace Outputs { +/*! + Provides the base class for an audio output source, with an input rate (the speed at which the source will + provide data), an output rate (the speed at which the destination will receive data), a delegate to receive + the output and some help for the output in picking an appropriate rate once the input rate is known. + + Intended to be a parent class, allowing descendants to pick the strategy by which input samples are mapped to + output samples. +*/ class Speaker { public: class Delegate { @@ -82,6 +90,16 @@ class Speaker { } }; +/*! + A concrete descendant of Speaker that uses a FIR filter to map from input data to output data when scaling + and a copy-through buffer when input and output rates are the same. + + Audio sources should use @c Filter as both a template and a parent, implementing at least + `get_samples(unsigned int quantity, int16_t *target)` and ideally also `skip_samples(unsigned int quantity)` + to provide source data. + + Call `run_for_cycles(n)` to request that the next n cycles of input data are collected. +*/ template class Filter: public Speaker { public: void run_for_cycles(unsigned int input_cycles) @@ -147,7 +165,7 @@ template class Filter: public Speaker { if(steps < _number_of_taps) { int16_t *input_buffer = _input_buffer.get(); - memmove(input_buffer, &input_buffer[steps], sizeof(int16_t) * ((size_t)_number_of_taps - (size_t)steps)); + memmove(input_buffer, &input_buffer[steps], sizeof(int16_t) * ((size_t)_number_of_taps - (size_t)steps)); _input_buffer_depth -= steps; } else