Update to v098r01 release.
byuu says:
Changelog:
- SFC: balanced profile removed
- SFC: performance profile removed
- SFC: code for handling non-threaded CPU, SMP, DSP, PPU removed
- SFC: Coprocessor, Controller (and expansion port) shared Thread code
merged to SFC::Cothread
- Cothread here just means "Thread with CPU affinity" (couldn't think
of a better name, sorry)
- SFC: CPU now has vector<Thread*> coprocessors, peripherals;
- this is the beginning of work to allow expansion port devices to be
dynamically changed at run-time
- ruby: all audio drivers default to 48000hz instead of 22050hz now if
no frequency is assigned
- note: the WASAPI driver can default to whatever the native frequency
is; doesn't have to be 48000hz
- tomoko: removed the ability to change the frequency from the UI (but
it will display the frequency used)
- tomoko: removed the timing settings panel
- the goal is to work toward smooth video via adaptive sync
- the model is broken by not being in control of the audio frequency
anyway
- it's further broken by PAL running at 50hz and WSC running at 75hz
- it was always broken anyway by SNES interlace timing varying from
progressive timing
- higan: audio/ stub created (for now, it's just nall/dsp/ moved here
and included as a header)
- higan: video/ stub created
- higan/GNUmakefile: now includes build rules for essential components
(libco, emulator, audio, video)
The audio changes are in preparation to merge wareya's awesome WASAPI
work without the need for the nall/dsp resampler.
2016-04-09 03:40:12 +00:00
|
|
|
#include <emulator/emulator.hpp>
|
|
|
|
|
Update to v098r06 release.
byuu says:
Changelog:
- emulation cores now refresh video from host thread instead of
cothreads (fix AMD crash)
- SFC: fixed another bug with leap year months in SharpRTC emulation
- SFC: cleaned up camelCase on function names for
armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes
- GB: added MBC1M emulation (requires manually setting mapper=MBC1M in
manifest.bml for now, sorry)
- audio: implemented Emulator::Audio mixer and effects processor
- audio: implemented Emulator::Stream interface
- it is now possible to have more than two audio streams: eg SNES
+ SGB + MSU1 + Voicer-Kun (eventually)
- audio: added reverb delay + reverb level settings; exposed balance
configuration in UI
- video: reworked palette generation to re-enable saturation, gamma,
luminance adjustments
- higan/emulator.cpp is gone since there was nothing left in it
I know you guys are going to say the color adjust/balance/reverb stuff
is pointless. And indeed it mostly is. But I like the idea of allowing
some fun special effects and configurability that isn't system-wide.
Note: there seems to be some kind of added audio lag in the SGB
emulation now, and I don't really understand why. The code should be
effectively identical to what I had before. The only main thing is that
I'm sampling things to 48000hz instead of 32040hz before mixing. There's
no point where I'm intentionally introducing added latency though. I'm
kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be
much appreciated :/
I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as
well, and that would be very bad.
2016-04-22 13:35:51 +00:00
|
|
|
namespace Emulator {
|
|
|
|
|
|
|
|
Audio audio;
|
|
|
|
|
|
|
|
Stream::Stream(double inputFrequency, double outputFrequency, double volume, double balance) {
|
|
|
|
dsp.setChannels(2);
|
|
|
|
dsp.setPrecision(16);
|
|
|
|
dsp.setFrequency(inputFrequency);
|
|
|
|
dsp.setResampler(DSP::ResampleEngine::Sinc);
|
|
|
|
dsp.setResamplerFrequency(outputFrequency);
|
|
|
|
dsp.setVolume(volume);
|
|
|
|
dsp.setBalance(balance);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Stream::sample(int16 left, int16 right) -> void {
|
|
|
|
int samples[] = {left, right};
|
|
|
|
dsp.sample(samples);
|
|
|
|
audio.poll();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
auto Audio::reset() -> void {
|
|
|
|
streams.reset();
|
|
|
|
setReverbDelay(reverbDelay);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Audio::setInterface(Interface* interface) -> void {
|
|
|
|
this->interface = interface;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Audio::setFrequency(double frequency) -> void {
|
|
|
|
this->frequency = frequency;
|
|
|
|
for(auto& stream : streams) stream->dsp.setResamplerFrequency(frequency);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Audio::setVolume(double volume) -> void {
|
|
|
|
this->volume = volume;
|
|
|
|
for(auto& stream : streams) stream->dsp.setVolume(volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Audio::setBalance(double balance) -> void {
|
|
|
|
this->balance = balance;
|
|
|
|
for(auto& stream : streams) stream->dsp.setBalance(balance);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Audio::setReverbDelay(uint reverbDelay) -> void {
|
|
|
|
this->reverbDelay = reverbDelay;
|
|
|
|
reverbLeft.resize(frequency * reverbDelay / 1000.0);
|
|
|
|
reverbRight.resize(frequency * reverbDelay / 1000.0);
|
|
|
|
memory::fill(reverbLeft.data(), reverbLeft.size() * sizeof(int16));
|
|
|
|
memory::fill(reverbRight.data(), reverbRight.size() * sizeof(int16));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Audio::setReverbLevel(double reverbLevel) -> void {
|
|
|
|
this->reverbLevel = reverbLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Audio::createStream(double frequency) -> shared_pointer<Stream> {
|
|
|
|
shared_pointer<Stream> stream = new Stream{frequency, this->frequency, volume, balance};
|
|
|
|
streams.append(stream);
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
//audio mixer
|
|
|
|
auto Audio::poll() -> void {
|
|
|
|
while(true) {
|
|
|
|
for(auto& stream : streams) {
|
|
|
|
if(!stream->dsp.pending()) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int left = 0, right = 0;
|
|
|
|
for(auto& stream : streams) {
|
|
|
|
int samples[2];
|
|
|
|
stream->dsp.read(samples);
|
|
|
|
left += samples[0];
|
|
|
|
right += samples[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(reverbDelay) {
|
|
|
|
reverbLeft.append(left);
|
|
|
|
reverbRight.append(right);
|
|
|
|
left += reverbLeft.takeFirst() * reverbLevel;
|
|
|
|
right += reverbRight.takeFirst() * reverbLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface->audioSample(sclamp<16>(left), sclamp<16>(right));
|
|
|
|
}
|
|
|
|
}
|
Update to v098r01 release.
byuu says:
Changelog:
- SFC: balanced profile removed
- SFC: performance profile removed
- SFC: code for handling non-threaded CPU, SMP, DSP, PPU removed
- SFC: Coprocessor, Controller (and expansion port) shared Thread code
merged to SFC::Cothread
- Cothread here just means "Thread with CPU affinity" (couldn't think
of a better name, sorry)
- SFC: CPU now has vector<Thread*> coprocessors, peripherals;
- this is the beginning of work to allow expansion port devices to be
dynamically changed at run-time
- ruby: all audio drivers default to 48000hz instead of 22050hz now if
no frequency is assigned
- note: the WASAPI driver can default to whatever the native frequency
is; doesn't have to be 48000hz
- tomoko: removed the ability to change the frequency from the UI (but
it will display the frequency used)
- tomoko: removed the timing settings panel
- the goal is to work toward smooth video via adaptive sync
- the model is broken by not being in control of the audio frequency
anyway
- it's further broken by PAL running at 50hz and WSC running at 75hz
- it was always broken anyway by SNES interlace timing varying from
progressive timing
- higan: audio/ stub created (for now, it's just nall/dsp/ moved here
and included as a header)
- higan: video/ stub created
- higan/GNUmakefile: now includes build rules for essential components
(libco, emulator, audio, video)
The audio changes are in preparation to merge wareya's awesome WASAPI
work without the need for the nall/dsp resampler.
2016-04-09 03:40:12 +00:00
|
|
|
|
|
|
|
}
|