mirror of https://github.com/bsnes-emu/bsnes.git
Fixed audio crackling in Super Game Boy emulation.
This commit is contained in:
parent
e598e81ab9
commit
e3f2e634c8
|
@ -56,13 +56,14 @@ struct Filter {
|
||||||
struct Stream {
|
struct Stream {
|
||||||
auto reset(uint channels, double inputFrequency, double outputFrequency) -> void;
|
auto reset(uint channels, double inputFrequency, double outputFrequency) -> void;
|
||||||
|
|
||||||
|
auto frequency() const -> double;
|
||||||
auto setFrequency(double inputFrequency, maybe<double> outputFrequency = nothing) -> void;
|
auto setFrequency(double inputFrequency, maybe<double> outputFrequency = nothing) -> void;
|
||||||
|
|
||||||
auto addDCRemovalFilter() -> void;
|
auto addDCRemovalFilter() -> void;
|
||||||
auto addLowPassFilter(double cutoffFrequency, Filter::Order order, uint passes = 1) -> void;
|
auto addLowPassFilter(double cutoffFrequency, Filter::Order order, uint passes = 1) -> void;
|
||||||
auto addHighPassFilter(double cutoffFrequency, Filter::Order order, uint passes = 1) -> void;
|
auto addHighPassFilter(double cutoffFrequency, Filter::Order order, uint passes = 1) -> void;
|
||||||
|
|
||||||
auto pending() const -> bool;
|
auto pending() const -> uint;
|
||||||
auto read(double samples[]) -> uint;
|
auto read(double samples[]) -> uint;
|
||||||
auto write(const double samples[]) -> void;
|
auto write(const double samples[]) -> void;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,10 @@ auto Stream::reset(uint channelCount, double inputFrequency, double outputFreque
|
||||||
setFrequency(inputFrequency, outputFrequency);
|
setFrequency(inputFrequency, outputFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto Stream::frequency() const -> double {
|
||||||
|
return inputFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
auto Stream::setFrequency(double inputFrequency, maybe<double> outputFrequency) -> void {
|
auto Stream::setFrequency(double inputFrequency, maybe<double> outputFrequency) -> void {
|
||||||
this->inputFrequency = inputFrequency;
|
this->inputFrequency = inputFrequency;
|
||||||
if(outputFrequency) this->outputFrequency = outputFrequency();
|
if(outputFrequency) this->outputFrequency = outputFrequency();
|
||||||
|
@ -77,8 +81,9 @@ auto Stream::addHighPassFilter(double cutoffFrequency, Filter::Order order, uint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Stream::pending() const -> bool {
|
auto Stream::pending() const -> uint {
|
||||||
return channels && channels[0].resampler.pending();
|
if(!channels) return 0;
|
||||||
|
return channels[0].resampler.pending();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Stream::read(double samples[]) -> uint {
|
auto Stream::read(double samples[]) -> uint {
|
||||||
|
|
|
@ -62,8 +62,8 @@ auto ICD::main() -> void {
|
||||||
auto clocks = GB_run(&sameboy);
|
auto clocks = GB_run(&sameboy);
|
||||||
step(clocks >> 1);
|
step(clocks >> 1);
|
||||||
} else { //DMG halted
|
} else { //DMG halted
|
||||||
stream->sample(float(0.0), float(0.0));
|
apuWrite(0.0, 0.0);
|
||||||
step(128);
|
step(256);
|
||||||
}
|
}
|
||||||
synchronizeCPU();
|
synchronizeCPU();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct queue {
|
||||||
template<typename U = T> auto capacity() const -> uint { return _capacity * sizeof(T) / sizeof(U); }
|
template<typename U = T> auto capacity() const -> uint { return _capacity * sizeof(T) / sizeof(U); }
|
||||||
template<typename U = T> auto size() const -> uint { return _size * sizeof(T) / sizeof(U); }
|
template<typename U = T> auto size() const -> uint { return _size * sizeof(T) / sizeof(U); }
|
||||||
auto empty() const -> bool { return _size == 0; }
|
auto empty() const -> bool { return _size == 0; }
|
||||||
auto pending() const -> bool { return _size > 0; }
|
auto pending() const -> bool { return _size; }
|
||||||
auto full() const -> bool { return _size >= (int)_capacity; }
|
auto full() const -> bool { return _size >= (int)_capacity; }
|
||||||
auto underflow() const -> bool { return _size < 0; }
|
auto underflow() const -> bool { return _size < 0; }
|
||||||
auto overflow() const -> bool { return _size > (int)_capacity; }
|
auto overflow() const -> bool { return _size > (int)_capacity; }
|
||||||
|
|
Loading…
Reference in New Issue