DSP HLE: Fixed a sound problem with a new Setup.h option. For some reason all the SoundSyncEvent->Set() caused a lot of static for me in Wario Land.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2236 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2009-02-14 01:07:20 +00:00
parent 94ee9afdb2
commit 94583cbab0
17 changed files with 215 additions and 167 deletions

View File

@ -15,10 +15,14 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include <dxerr.h>
#include "DSoundStream.h"
#include "../main.h"
#include "WaveFile.h"
#include <dxerr.h>
extern bool log_ai;
extern WaveFileWriter g_wave_writer;
bool DSound::CreateBuffer()
{
@ -59,6 +63,11 @@ bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write
char* soundData, // Start of our data.
DWORD dwSoundBytes) // Size of block to copy.
{
// I want to record the regular audio to, how do I do that?
//std::string Data = ArrayToString((const u8*)soundData, dwSoundBytes);
//Console::Print("Data: %s\n\n", Data.c_str());
//if (log_ai) g_wave_writer.AddStereoSamples((const short*)soundData, dwSoundBytes);
void* ptr1, * ptr2;
DWORD numBytes1, numBytes2;
// Obtain memory address of write block. This will be in two parts if the block wraps around.

View File

@ -48,9 +48,11 @@ volatile bool mixer_HLEready = false;
volatile int queue_size = 0;
bool bThrottling = false;
void UpdateThrottle(bool update) {
/* What is this for?
void UpdateThrottle(bool update)
{
bThrottling = update;
}
}*/
void Mixer(short *buffer, int numSamples, int bits, int rate, int channels)
{
@ -101,11 +103,14 @@ void Mixer_MixUCode(short *buffer, int numSamples, int bits, int rate,
}
}
void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate) {
void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
{
// We alredady do this with the WaveFileWriter right? So no need for this to?
// static FILE *f;
// if (!f)
// f = fopen("d:\\hello.raw", "wb");
// fwrite(buffer, num_stereo_samples * 4, 1, f);
if (queue_size == 0)
{
queue_size = queue_minlength;
@ -117,83 +122,83 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate) {
static int PV1r=0,PV2r=0,PV3r=0,PV4r=0;
static int acc=0;
bThrottling = g_Config.m_EnableThrottle;
// Write Other Audio
//bThrottling = g_Config.m_EnableThrottle;
if(g_Config.m_EnableThrottle)
{
if(bThrottling) {
/* This is only needed for non-AX sound, currently directly
streamed and DTK sound. For AX we call SoundStream::Update in
AXTask() for example. */
while (queue_size > queue_maxlength / 2) {
soundStream->Update();
Common::SleepCurrentThread(0);
}
//convert into config option?
const int mode = 2;
push_sync.Enter();
while (num_stereo_samples)
{
acc += sample_rate;
while (num_stereo_samples && (acc >= 48000))
{
PV4l=PV3l;
PV3l=PV2l;
PV2l=PV1l;
PV1l=*(buffer++); //32bit processing
PV4r=PV3r;
PV3r=PV2r;
PV2r=PV1r;
PV1r=*(buffer++); //32bit processing
num_stereo_samples--;
acc-=48000;
}
// defaults to nearest
s32 DataL = PV1l;
s32 DataR = PV1r;
if (mode == 1) //linear
{
DataL = PV1l + ((PV2l - PV1l)*acc)/48000;
DataR = PV1r + ((PV2r - PV1r)*acc)/48000;
}
else if (mode == 2) //cubic
{
s32 a0l = PV1l - PV2l - PV4l + PV3l;
s32 a0r = PV1r - PV2r - PV4r + PV3r;
s32 a1l = PV4l - PV3l - a0l;
s32 a1r = PV4r - PV3r - a0r;
s32 a2l = PV1l - PV4l;
s32 a2r = PV1r - PV4r;
s32 a3l = PV2l;
s32 a3r = PV2r;
s32 t0l = ((a0l )*acc)/48000;
s32 t0r = ((a0r )*acc)/48000;
s32 t1l = ((t0l+a1l)*acc)/48000;
s32 t1r = ((t0r+a1r)*acc)/48000;
s32 t2l = ((t1l+a2l)*acc)/48000;
s32 t2r = ((t1r+a2r)*acc)/48000;
s32 t3l = ((t2l+a3l));
s32 t3r = ((t2r+a3r));
DataL = t3l;
DataR = t3r;
}
int l = DataL, r = DataR;
if (l < -32767) l = -32767;
if (r < -32767) r = -32767;
if (l > 32767) l = 32767;
if (r > 32767) r = 32767;
sample_queue.push(l);
sample_queue.push(r);
queue_size += 2;
}
push_sync.Leave();
/* This is only needed for non-AX sound, currently directly
streamed and DTK sound. For AX we call SoundStream::Update in
AXTask() for example. */
while (queue_size > queue_maxlength / 2) {
soundStream->Update();
Common::SleepCurrentThread(0);
}
//convert into config option?
const int mode = 2;
push_sync.Enter();
while (num_stereo_samples)
{
acc += sample_rate;
while (num_stereo_samples && (acc >= 48000))
{
PV4l=PV3l;
PV3l=PV2l;
PV2l=PV1l;
PV1l=*(buffer++); //32bit processing
PV4r=PV3r;
PV3r=PV2r;
PV2r=PV1r;
PV1r=*(buffer++); //32bit processing
num_stereo_samples--;
acc-=48000;
}
// defaults to nearest
s32 DataL = PV1l;
s32 DataR = PV1r;
if (mode == 1) //linear
{
DataL = PV1l + ((PV2l - PV1l)*acc)/48000;
DataR = PV1r + ((PV2r - PV1r)*acc)/48000;
}
else if (mode == 2) //cubic
{
s32 a0l = PV1l - PV2l - PV4l + PV3l;
s32 a0r = PV1r - PV2r - PV4r + PV3r;
s32 a1l = PV4l - PV3l - a0l;
s32 a1r = PV4r - PV3r - a0r;
s32 a2l = PV1l - PV4l;
s32 a2r = PV1r - PV4r;
s32 a3l = PV2l;
s32 a3r = PV2r;
s32 t0l = ((a0l )*acc)/48000;
s32 t0r = ((a0r )*acc)/48000;
s32 t1l = ((t0l+a1l)*acc)/48000;
s32 t1r = ((t0r+a1r)*acc)/48000;
s32 t2l = ((t1l+a2l)*acc)/48000;
s32 t2r = ((t1r+a2r)*acc)/48000;
s32 t3l = ((t2l+a3l));
s32 t3r = ((t2r+a3r));
DataL = t3l;
DataR = t3r;
}
int l = DataL, r = DataR;
if (l < -32767) l = -32767;
if (r < -32767) r = -32767;
if (l > 32767) l = 32767;
if (r > 32767) r = 32767;
sample_queue.push(l);
sample_queue.push(r);
queue_size += 2;
}
push_sync.Leave();
}
}