2011-09-27 11:55:02 +00:00
|
|
|
struct Audio {
|
2010-08-09 13:28:56 +00:00
|
|
|
void coprocessor_enable(bool state);
|
|
|
|
void coprocessor_frequency(double frequency);
|
2011-09-27 11:55:02 +00:00
|
|
|
void sample(int16 lsample, int16 rsample);
|
|
|
|
void coprocessor_sample(int16 lsample, int16 rsample);
|
2010-08-09 13:28:56 +00:00
|
|
|
void init();
|
|
|
|
|
|
|
|
private:
|
2011-08-20 14:40:44 +00:00
|
|
|
nall::DSP dspaudio;
|
2011-09-27 11:55:02 +00:00
|
|
|
bool coprocessor;
|
2011-08-20 14:40:44 +00:00
|
|
|
enum : unsigned { buffer_size = 256, buffer_mask = buffer_size - 1 };
|
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
|
|
|
uint32 dsp_buffer[buffer_size], cop_buffer[buffer_size];
|
2010-08-09 13:28:56 +00:00
|
|
|
unsigned dsp_rdoffset, cop_rdoffset;
|
|
|
|
unsigned dsp_wroffset, cop_wroffset;
|
|
|
|
unsigned dsp_length, cop_length;
|
|
|
|
|
|
|
|
void flush();
|
|
|
|
};
|
|
|
|
|
|
|
|
extern Audio audio;
|