mirror of https://github.com/xemu-project/xemu.git
apu: Add mixbin beep tone for debugging
This commit is contained in:
parent
f2901a24d4
commit
c5962e0920
|
@ -24,6 +24,7 @@
|
||||||
#include "hw/pci/pci.h"
|
#include "hw/pci/pci.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "hw/xbox/dsp/dsp.h"
|
#include "hw/xbox/dsp/dsp.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#define NUM_SAMPLES_PER_FRAME 32
|
#define NUM_SAMPLES_PER_FRAME 32
|
||||||
#define NUM_MIXBINS 32
|
#define NUM_MIXBINS 32
|
||||||
|
@ -187,6 +188,9 @@ static const struct {
|
||||||
# define MCPX_DPRINTF(format, ...) do { } while (0)
|
# define MCPX_DPRINTF(format, ...) do { } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* More debug functionality */
|
||||||
|
#define GENERATE_MIXBIN_BEEP 0
|
||||||
|
|
||||||
typedef struct MCPXAPUState {
|
typedef struct MCPXAPUState {
|
||||||
PCIDevice dev;
|
PCIDevice dev;
|
||||||
|
|
||||||
|
@ -855,6 +859,21 @@ static void se_frame(void *opaque)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GENERATE_MIXBIN_BEEP
|
||||||
|
/* Inject some audio to the mixbin for debugging.
|
||||||
|
* Signal is 1500 Hz sine wave, phase shifted by mixbin number. */
|
||||||
|
for (mixbin = 0; mixbin < NUM_MIXBINS; mixbin++) {
|
||||||
|
for (sample = 0; sample < NUM_SAMPLES_PER_FRAME; sample++) {
|
||||||
|
/* Avoid multiple of 1.0 / NUM_SAMPLES_PER_FRAME for phase shift,
|
||||||
|
* or waves cancel out */
|
||||||
|
float offset = sample / (float)NUM_SAMPLES_PER_FRAME -
|
||||||
|
mixbin / (float)(NUM_SAMPLES_PER_FRAME + 1);
|
||||||
|
float wave = sinf(offset * M_PI * 2.0f);
|
||||||
|
mixbins[mixbin][sample] += wave * 0x3FFFFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Write VP results to the GP DSP MIXBUF */
|
/* Write VP results to the GP DSP MIXBUF */
|
||||||
for (mixbin = 0; mixbin < NUM_MIXBINS; mixbin++) {
|
for (mixbin = 0; mixbin < NUM_MIXBINS; mixbin++) {
|
||||||
for (sample = 0; sample < NUM_SAMPLES_PER_FRAME; sample++) {
|
for (sample = 0; sample < NUM_SAMPLES_PER_FRAME; sample++) {
|
||||||
|
|
Loading…
Reference in New Issue