mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Merge branch 'master' of github.com:TomHarte/CLK
This commit is contained in:
commit
2bc87ee095
@ -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:
|
||||
|
@ -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 T> class Filter: public Speaker {
|
||||
public:
|
||||
void run_for_cycles(unsigned int input_cycles)
|
||||
@ -147,7 +165,7 @@ template <class T> 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
|
||||
|
Loading…
Reference in New Issue
Block a user