2010-08-09 13:28:56 +00:00
|
|
|
#ifdef SYSTEM_CPP
|
|
|
|
|
|
|
|
Audio audio;
|
|
|
|
|
|
|
|
void Audio::coprocessor_enable(bool state) {
|
|
|
|
coprocessor = state;
|
2011-08-20 14:40:44 +00:00
|
|
|
dspaudio.clear();
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
dsp_rdoffset = cop_rdoffset = 0;
|
|
|
|
dsp_wroffset = cop_wroffset = 0;
|
|
|
|
dsp_length = cop_length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio::coprocessor_frequency(double input_frequency) {
|
2011-08-20 14:40:44 +00:00
|
|
|
dspaudio.setFrequency(input_frequency);
|
2011-09-24 09:51:08 +00:00
|
|
|
dspaudio.setResampler(nall::DSP::ResampleEngine::Sinc);
|
2015-11-10 11:02:29 +00:00
|
|
|
dspaudio.setResamplerFrequency(system.apuFrequency() / 768.0);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2011-09-27 11:55:02 +00:00
|
|
|
void Audio::sample(int16 lsample, int16 rsample) {
|
|
|
|
if(coprocessor == false) return interface->audioSample(lsample, rsample);
|
|
|
|
|
|
|
|
dsp_buffer[dsp_wroffset] = ((uint16)lsample << 0) + ((uint16)rsample << 16);
|
|
|
|
dsp_wroffset = (dsp_wroffset + 1) & buffer_mask;
|
|
|
|
dsp_length = (dsp_length + 1) & buffer_mask;
|
|
|
|
flush();
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2011-09-16 11:44:07 +00:00
|
|
|
void Audio::coprocessor_sample(int16 lsample, int16 rsample) {
|
2013-05-05 09:21:30 +00:00
|
|
|
signed samples[] = {lsample, rsample};
|
2011-09-16 11:44:07 +00:00
|
|
|
dspaudio.sample(samples);
|
2011-08-20 14:40:44 +00:00
|
|
|
while(dspaudio.pending()) {
|
2011-09-16 11:44:07 +00:00
|
|
|
dspaudio.read(samples);
|
2011-08-20 14:40:44 +00:00
|
|
|
|
2011-09-16 11:44:07 +00:00
|
|
|
cop_buffer[cop_wroffset] = ((uint16)samples[0] << 0) + ((uint16)samples[1] << 16);
|
2011-08-20 14:40:44 +00:00
|
|
|
cop_wroffset = (cop_wroffset + 1) & buffer_mask;
|
|
|
|
cop_length = (cop_length + 1) & buffer_mask;
|
|
|
|
flush();
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio::init() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio::flush() {
|
|
|
|
while(dsp_length > 0 && cop_length > 0) {
|
|
|
|
uint32 dsp_sample = dsp_buffer[dsp_rdoffset];
|
|
|
|
uint32 cop_sample = cop_buffer[cop_rdoffset];
|
|
|
|
|
Update to v075r06 release.
byuu says:
Removed the floating-point volume adjustments from the wave channel and
the left/right speaker mixers. Also, against my better judgment I'm
backing out of left/right computation when they are both turned off.
This basically makes non-stereo games run faster, but will make stereo
games appear to run slower. I don't like it when end-users experience
mystery slowdowns.
Anyway, it appears that the audio calculation is really fucking
demanding. Knocks FPS from 800 down to 300. I thought it might be libco,
so I took it out and it only went up to 305fps o.O
There is also some sort of problem with bsnes/Super Game Boy audio. The
latency is really great when you first start, but it seems to drift
apart over time until it is well over 500ms, and then it either pops or
fades back to very low, sub-50ms latency again. The way I handle mixing
is that the coprocessor audio samples go into a resampler to the native
SNES rate, and fed to an output buffer. SNES audio samples go there
untouched. When there is a sample in each, I add them together and
average the result (I still don't understand why we divide by two since
these are signed integers), and output it immediately. It's just-in-time
sampling, so as long as DSP v Coprocessor do not drift very far, it
should have very low latency. And I make the CPU sync DSP and
Coprocessor once per scanline, which is something like 15 samples or so.
2011-02-03 11:17:35 +00:00
|
|
|
dsp_rdoffset = (dsp_rdoffset + 1) & buffer_mask;
|
|
|
|
cop_rdoffset = (cop_rdoffset + 1) & buffer_mask;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
dsp_length--;
|
|
|
|
cop_length--;
|
|
|
|
|
2011-09-27 11:55:02 +00:00
|
|
|
signed dsp_left = (int16)(dsp_sample >> 0);
|
|
|
|
signed dsp_right = (int16)(dsp_sample >> 16);
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2011-09-27 11:55:02 +00:00
|
|
|
signed cop_left = (int16)(cop_sample >> 0);
|
|
|
|
signed cop_right = (int16)(cop_sample >> 16);
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2011-09-15 12:41:49 +00:00
|
|
|
interface->audioSample(
|
Update to v094r08 release.
byuu says:
Lots of changes this time around. FreeBSD stability and compilation is
still a work in progress.
FreeBSD 10 + Clang 3.3 = 108fps
FreeBSD 10 + GCC 4.7 = 130fps
Errata 1: I've been fighting that god-damned endian.h header for the
past nine WIPs now. The above WIP isn't building now because FreeBSD
isn't including headers before using certain types, and you end up with
a trillion error messages. So just delete all the endian.h includes from
nall/intrinsics.hpp to build.
Errata 2: I was trying to match g++ and g++47, so I used $(findstring
g++,$(compiler)), which ends up also matching clang++. Oops. Easy fix,
put Clang first and then else if g++ next. Not ideal, but oh well. All
it's doing for now is declaring -fwrapv twice, so you don't have to fix
it just yet. Probably just going to alias g++="g++47" and do exact
matching instead.
Errata 3: both OpenGL::term and VideoGLX::term are causing a core dump
on BSD. No idea why. The resources are initialized and valid, but
releasing them crashes the application.
Changelog:
- nall/Makefile is more flexible with overriding $(compiler), so you can
build with GCC or Clang on BSD (defaults to GCC now)
- PLATFORM_X was renamed to PLATFORM_XORG, and it's also declared with
PLATFORM_LINUX or PLATFORM_BSD
- PLATFORM_XORG probably isn't the best name ... still thinking about
what best to call LINUX|BSD|SOLARIS or ^(WINDOWS|MACOSX)
- fixed a few legitimate Clang warning messages in nall
- Compiler::VisualCPP is ugly as hell, renamed to Compiler::CL
- nall/platform includes nall/intrinsics first. Trying to move away from
testing for _WIN32, etc directly in all files. Work in progress.
- nall turns off Clang warnings that I won't "fix", because they aren't
broken. It's much less noisy to compile with warnings on now.
- phoenix gains the ability to set background and foreground colors on
various text container widgets (GTK only for now.)
- rewrote a lot of the MSU1 code to try and simplify it. Really hope
I didn't break anything ... I don't have any MSU1 test ROMs handy
- SNES coprocessor audio is now mixed as sclamp<16>(system_sample
+ coprocessor_sample) instead of sclamp<16>((sys + cop) / 2)
- allows for greater chance of aliasing (still low, SNES audio is
quiet), but doesn't cut base system volume in half anymore
- fixed Super Scope and Justifier cursor colors
- use input.xlib instead of input.x ... allows Xlib input driver to be
visible on Linux and BSD once again
- make install and make uninstall must be run as root again; no longer
using install but cp instead for BSD compatibility
- killed $(DESTDIR) ... use make prefix=$DESTDIR$prefix instead
- you can now set text/background colors for the loki console via (eg):
- settings.terminal.background-color 0x000000
- settings.terminal.foreground-color 0xffffff
2014-02-24 09:39:09 +00:00
|
|
|
sclamp<16>(dsp_left + cop_left ),
|
|
|
|
sclamp<16>(dsp_right + cop_right)
|
2010-08-09 13:28:56 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|