mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 01:31:42 +00:00
Filter
is now a ClockReciever
, affecting all sound output devices.
This commit is contained in:
parent
677ed463f0
commit
b7f88e8f61
@ -408,7 +408,7 @@ template <class T> class MOS6560 {
|
||||
std::shared_ptr<Speaker> speaker_;
|
||||
unsigned int cycles_since_speaker_update_;
|
||||
void update_audio() {
|
||||
speaker_->run_for_cycles(cycles_since_speaker_update_ >> 2);
|
||||
speaker_->run_for(Cycles((int)cycles_since_speaker_update_ >> 2));
|
||||
cycles_since_speaker_update_ &= 3;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class Bus {
|
||||
inline void update_audio() {
|
||||
unsigned int audio_cycles = cycles_since_speaker_update_ / (CPUTicksPerAudioTick * 3);
|
||||
cycles_since_speaker_update_ %= (CPUTicksPerAudioTick * 3);
|
||||
speaker_->run_for_cycles(audio_cycles);
|
||||
speaker_->run_for(Cycles((int)audio_cycles));
|
||||
}
|
||||
|
||||
// video backlog accumulation counter
|
||||
|
@ -368,7 +368,7 @@ inline void Machine::update_audio() {
|
||||
if(cycles_since_audio_update_) {
|
||||
unsigned int difference = cycles_since_audio_update_ / Speaker::clock_rate_divider;
|
||||
cycles_since_audio_update_ %= Speaker::clock_rate_divider;
|
||||
speaker_->run_for_cycles(difference);
|
||||
speaker_->run_for(Cycles((int)difference));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ uint8_t Machine::VIA::get_port_input(Port port) {
|
||||
}
|
||||
|
||||
void Machine::VIA::flush() {
|
||||
ay8910->run_for_cycles(cycles_since_ay_update_);
|
||||
ay8910->run_for(Cycles((int)cycles_since_ay_update_));
|
||||
ay8910->flush();
|
||||
cycles_since_ay_update_ = 0;
|
||||
}
|
||||
@ -247,7 +247,7 @@ void Machine::VIA::run_for_cycles(unsigned int number_of_cycles) {
|
||||
}
|
||||
|
||||
void Machine::VIA::update_ay() {
|
||||
ay8910->run_for_cycles(cycles_since_ay_update_);
|
||||
ay8910->run_for(Cycles((int)cycles_since_ay_update_));
|
||||
cycles_since_ay_update_ = 0;
|
||||
ay8910->set_control_lines( (GI::AY38910::ControlLines)((ay_bdir_ ? GI::AY38910::BCDIR : 0) | (ay_bc1_ ? GI::AY38910::BC1 : 0) | GI::AY38910::BC2));
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "../SignalProcessing/Stepper.hpp"
|
||||
#include "../SignalProcessing/FIRFilter.hpp"
|
||||
#include "../Concurrency/AsyncTaskQueue.hpp"
|
||||
#include "../Components/ClockReceiver.hpp"
|
||||
|
||||
namespace Outputs {
|
||||
|
||||
@ -132,17 +133,17 @@ class Speaker {
|
||||
`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.
|
||||
Call `run_for` to request that the next period of input data is collected.
|
||||
*/
|
||||
template <class T> class Filter: public Speaker {
|
||||
template <class T> class Filter: public Speaker, public ClockReceiver<Filter<T>> {
|
||||
public:
|
||||
~Filter() {
|
||||
_queue->flush();
|
||||
}
|
||||
|
||||
void run_for_cycles(unsigned int input_cycles) {
|
||||
void run_for(const Cycles &cycles) {
|
||||
enqueue([=]() {
|
||||
unsigned int cycles_remaining = input_cycles;
|
||||
unsigned int cycles_remaining = (unsigned int)cycles.as_int();
|
||||
if(coefficients_are_dirty_) update_filter_coefficients();
|
||||
|
||||
// if input and output rates exactly match, just accumulate results and pass on
|
||||
|
Loading…
Reference in New Issue
Block a user