Changed SoundTouch to use float samples, allowing SSE to be used.

Made the DPL2 decoder disabled by default.
Re-added the audio hack used by the Accurate VBeam emulation option.
This commit is contained in:
skidau 2013-01-15 22:29:26 +11:00
parent 1c462a1eca
commit 6d4a566bc4
6 changed files with 32 additions and 17 deletions

View File

@ -103,8 +103,8 @@ namespace soundtouch
/// However, if you still prefer to select the sample format here /// However, if you still prefer to select the sample format here
/// also in GNU environment, then please #undef the INTEGER_SAMPLE /// also in GNU environment, then please #undef the INTEGER_SAMPLE
/// and FLOAT_SAMPLE defines first as in comments above. /// and FLOAT_SAMPLE defines first as in comments above.
#define SOUNDTOUCH_INTEGER_SAMPLES 1 //< 16bit integer samples //#define SOUNDTOUCH_INTEGER_SAMPLES 1 //< 16bit integer samples
//#define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples #define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples
#endif #endif

View File

@ -176,6 +176,7 @@ void OpenALStream::SoundLoop()
soundTouch.setChannels(2); soundTouch.setChannels(2);
soundTouch.setSampleRate(ulFrequency); soundTouch.setSampleRate(ulFrequency);
soundTouch.setTempo(1.0);
soundTouch.setSetting(SETTING_USE_QUICKSEEK, 0); soundTouch.setSetting(SETTING_USE_QUICKSEEK, 0);
soundTouch.setSetting(SETTING_USE_AA_FILTER, 0); soundTouch.setSetting(SETTING_USE_AA_FILTER, 0);
soundTouch.setSetting(SETTING_SEQUENCE_MS, 1); soundTouch.setSetting(SETTING_SEQUENCE_MS, 1);
@ -197,7 +198,16 @@ void OpenALStream::SoundLoop()
numSamples = (numSamples > OAL_MAX_SAMPLES) ? OAL_MAX_SAMPLES : numSamples; numSamples = (numSamples > OAL_MAX_SAMPLES) ? OAL_MAX_SAMPLES : numSamples;
numSamples = m_mixer->Mix(realtimeBuffer, numSamples); numSamples = m_mixer->Mix(realtimeBuffer, numSamples);
soundTouch.putSamples(realtimeBuffer, numSamples);
// Convert the samples from short to float
float dest[OAL_MAX_SAMPLES * 2 * 2 * OAL_MAX_BUFFERS];
for (u32 i = 0; i < numSamples; ++i)
{
dest[i * 2 + 0] = (float)realtimeBuffer[i * 2 + 0] / (1 << 16);
dest[i * 2 + 1] = (float)realtimeBuffer[i * 2 + 1] / (1 << 16);
}
soundTouch.putSamples(dest, numSamples);
if (iBuffersProcessed == iBuffersFilled) if (iBuffersProcessed == iBuffersFilled)
{ {
@ -241,16 +251,8 @@ void OpenALStream::SoundLoop()
#else #else
if (surround_capable) if (surround_capable)
{ {
// Convert the samples from short to float for the dpl2 decoder
float dest[OAL_MAX_SAMPLES * 2 * 2 * OAL_MAX_BUFFERS];
for (u32 i = 0; i < nSamples; ++i)
{
dest[i * 2 + 0] = (float)sampleBuffer[i * 2 + 0] / (1<<16);
dest[i * 2 + 1] = (float)sampleBuffer[i * 2 + 1] / (1<<16);
}
float dpl2[OAL_MAX_SAMPLES * SIZE_FLOAT * SURROUND_CHANNELS * OAL_MAX_BUFFERS]; float dpl2[OAL_MAX_SAMPLES * SIZE_FLOAT * SURROUND_CHANNELS * OAL_MAX_BUFFERS];
dpl2decode(dest, nSamples, dpl2); dpl2decode(sampleBuffer, nSamples, dpl2);
alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_51CHN32, dpl2, nSamples * SIZE_FLOAT * SURROUND_CHANNELS, ulFrequency); alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_51CHN32, dpl2, nSamples * SIZE_FLOAT * SURROUND_CHANNELS, ulFrequency);
ALenum err = alGetError(); ALenum err = alGetError();
@ -268,7 +270,18 @@ void OpenALStream::SoundLoop()
#endif #endif
if (!surround_capable) if (!surround_capable)
{ {
alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_STEREO16, sampleBuffer, nSamples * 2 * 2, ulFrequency); #if defined(__APPLE__)
// Convert the samples from float to short
short stereo[OAL_MAX_SAMPLES * 2 * 2 * OAL_MAX_BUFFERS];
for (u32 i = 0; i < nSamples; ++i)
{
stereo[i * 2 + 0] = (short)((float)sampleBuffer[i * 2 + 0] * (1 << 16));
stereo[i * 2 + 1] = (short)((float)sampleBuffer[i * 2 + 1] * (1 << 16));
}
alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_STEREO16, stereo, nSamples * 2 * 2, ulFrequency);
#else
alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_STEREO_FLOAT32, sampleBuffer, nSamples * 4 * 2, ulFrequency);
#endif
} }
alSourceQueueBuffers(uiSource, 1, &uiBufferTemp[iBuffersFilled]); alSourceQueueBuffers(uiSource, 1, &uiBufferTemp[iBuffersFilled]);

View File

@ -369,7 +369,7 @@ void SConfig::LoadSettings()
ini.Get("Core", "Apploader", &m_LocalCoreStartupParameter.m_strApploader); ini.Get("Core", "Apploader", &m_LocalCoreStartupParameter.m_strApploader);
ini.Get("Core", "EnableCheats", &m_LocalCoreStartupParameter.bEnableCheats, false); ini.Get("Core", "EnableCheats", &m_LocalCoreStartupParameter.bEnableCheats, false);
ini.Get("Core", "SelectedLanguage", &m_LocalCoreStartupParameter.SelectedLanguage, 0); ini.Get("Core", "SelectedLanguage", &m_LocalCoreStartupParameter.SelectedLanguage, 0);
ini.Get("Core", "DPL2Decoder", &m_LocalCoreStartupParameter.bDPL2Decoder, true); ini.Get("Core", "DPL2Decoder", &m_LocalCoreStartupParameter.bDPL2Decoder, false);
ini.Get("Core", "Latency", &m_LocalCoreStartupParameter.iLatency, 14); ini.Get("Core", "Latency", &m_LocalCoreStartupParameter.iLatency, 14);
ini.Get("Core", "MemcardA", &m_strMemoryCardA); ini.Get("Core", "MemcardA", &m_strMemoryCardA);
ini.Get("Core", "MemcardB", &m_strMemoryCardB); ini.Get("Core", "MemcardB", &m_strMemoryCardB);

View File

@ -49,7 +49,7 @@ SCoreStartupParameter::SCoreStartupParameter()
bEnableCheats(false), bEnableCheats(false),
bMergeBlocks(false), bMergeBlocks(false),
bRunCompareServer(false), bRunCompareClient(false), bRunCompareServer(false), bRunCompareClient(false),
bDPL2Decoder(true), iLatency(14), bDPL2Decoder(false), iLatency(14),
bMMU(false), bMMUBAT(false), iTLBHack(0), bVBeam(false), bMMU(false), bMMUBAT(false), iTLBHack(0), bVBeam(false),
bFastDiscSpeed(false), bFastDiscSpeed(false),
SelectedLanguage(0), bWii(false), bDisableWiimoteSpeaker(false), SelectedLanguage(0), bWii(false), bDisableWiimoteSpeaker(false),
@ -85,7 +85,7 @@ void SCoreStartupParameter::LoadDefaults()
bMergeBlocks = false; bMergeBlocks = false;
SelectedLanguage = 0; SelectedLanguage = 0;
bWii = false; bWii = false;
bDPL2Decoder = true; bDPL2Decoder = false;
iLatency = 14; iLatency = 14;
iPosX = 100; iPosX = 100;

View File

@ -160,7 +160,8 @@ void DSPCallback(u64 userdata, int cyclesLate)
void AudioDMACallback(u64 userdata, int cyclesLate) void AudioDMACallback(u64 userdata, int cyclesLate)
{ {
int period = CPU_CORE_CLOCK / (AudioInterface::GetAIDSampleRate() * 4 / 32); int fields = SConfig::GetInstance().m_LocalCoreStartupParameter.bVBeam?2:1;
int period = CPU_CORE_CLOCK / (AudioInterface::GetAIDSampleRate() * 4 / 32 * fields);
DSP::UpdateAudioDMA(); // Push audio to speakers. DSP::UpdateAudioDMA(); // Push audio to speakers.
CoreTiming::ScheduleEvent(period - cyclesLate, et_AudioDMA); CoreTiming::ScheduleEvent(period - cyclesLate, et_AudioDMA);
} }

View File

@ -366,6 +366,7 @@ void CConfigMain::InitializeGUIValues()
VolumeText->SetLabel(wxString::Format(wxT("%d %%"), ac_Config.m_Volume)); VolumeText->SetLabel(wxString::Format(wxT("%d %%"), ac_Config.m_Volume));
DSPThread->SetValue(startup_params.bDSPThread); DSPThread->SetValue(startup_params.bDSPThread);
DumpAudio->SetValue(ac_Config.m_DumpAudio ? true : false); DumpAudio->SetValue(ac_Config.m_DumpAudio ? true : false);
DPL2Decoder->Enable(std::string(ac_Config.sBackend) == BACKEND_OPENAL);
DPL2Decoder->SetValue(startup_params.bDPL2Decoder); DPL2Decoder->SetValue(startup_params.bDPL2Decoder);
LatencySlider->Enable(std::string(ac_Config.sBackend) == BACKEND_OPENAL); LatencySlider->Enable(std::string(ac_Config.sBackend) == BACKEND_OPENAL);
LatencySlider->SetValue(startup_params.iLatency); LatencySlider->SetValue(startup_params.iLatency);