Merge pull request #2638 from bagnz0r/master

Audio optimization, usability fixes, sound peak blowout fix, Polish translation, bugfixes
This commit is contained in:
Henrik Rydgård 2013-07-18 02:54:03 -07:00
commit 05dfd27db8
5 changed files with 20 additions and 6 deletions

View file

@ -134,8 +134,8 @@ void Config::Load(const char *iniFileName)
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound"); IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
sound->Get("Enable", &bEnableSound, true); sound->Get("Enable", &bEnableSound, true);
sound->Get("EnableAtrac3plus", &bEnableAtrac3plus, true); sound->Get("EnableAtrac3plus", &bEnableAtrac3plus, true);
sound->Get("BGMVolume", &iBGMVolume, 4); sound->Get("BGMVolume", &iBGMVolume, 5);
sound->Get("SEVolume", &iSEVolume, 4); sound->Get("SEVolume", &iSEVolume, 5);
IniFile::Section *control = iniFile.GetOrCreateSection("Control"); IniFile::Section *control = iniFile.GetOrCreateSection("Control");
control->Get("ShowStick", &bShowAnalogStick, false); control->Get("ShowStick", &bShowAnalogStick, false);

View file

@ -29,6 +29,8 @@
#include "FixedSizeQueue.h" #include "FixedSizeQueue.h"
#include "Common/Thread.h" #include "Common/Thread.h"
#define LOW_LATENCY_AUDIO false
// Should be used to lock anything related to the outAudioQueue. // Should be used to lock anything related to the outAudioQueue.
recursive_mutex section; recursive_mutex section;
@ -37,15 +39,27 @@ int eventHostAudioUpdate = -1;
int mixFrequency = 44100; int mixFrequency = 44100;
const int hwSampleRate = 44100; const int hwSampleRate = 44100;
#ifdef LOW_LATENCY_AUDIO
const int hwBlockSize = 16;
const int hostAttemptBlockSize = 256;
#else
const int hwBlockSize = 64; const int hwBlockSize = 64;
const int hostAttemptBlockSize = 512; const int hostAttemptBlockSize = 512;
#endif;
const int audioIntervalUs = (int)(1000000ULL * hwBlockSize / hwSampleRate); const int audioIntervalUs = (int)(1000000ULL * hwBlockSize / hwSampleRate);
const int audioHostIntervalUs = (int)(1000000ULL * hostAttemptBlockSize / hwSampleRate); const int audioHostIntervalUs = (int)(1000000ULL * hostAttemptBlockSize / hwSampleRate);
// High and low watermarks, basically. For perfect emulation, the correct values are 0 and 1, respectively. // High and low watermarks, basically. For perfect emulation, the correct values are 0 and 1, respectively.
// TODO: Tweak // TODO: Tweak
#ifdef LOW_LATENCY_AUDIO
const int chanQueueMaxSizeFactor = 0;
const int chanQueueMinSizeFactor = 1;
#else
const int chanQueueMaxSizeFactor = 2; const int chanQueueMaxSizeFactor = 2;
const int chanQueueMinSizeFactor = 1; const int chanQueueMinSizeFactor = 1;
#endif
// TODO: Need to replace this with something lockless. Mutexes in the audio pipeline // TODO: Need to replace this with something lockless. Mutexes in the audio pipeline
// is bad mojo. // is bad mojo.

View file

@ -625,7 +625,7 @@ u32 _AtracDecodeData(int atracID, u8* outbuf, u32 *SamplesNum, u32* finish, int
atrac->sampleQueue.push(buf, decodebytes); atrac->sampleQueue.push(buf, decodebytes);
} }
} }
const int MAX_CONFIG_VOLUME = 5; const int MAX_CONFIG_VOLUME = 8;
s16* out = (s16*)outbuf; s16* out = (s16*)outbuf;
memset(out, 0, ATRAC3PLUS_MAX_SAMPLES * sizeof(s16) * atrac->atracOutputChannels); memset(out, 0, ATRAC3PLUS_MAX_SAMPLES * sizeof(s16) * atrac->atracOutputChannels);
int gotsize = atrac->sampleQueue.pop_front(buf, ATRAC3PLUS_MAX_SAMPLES * sizeof(s16) * atrac->atracChannels); int gotsize = atrac->sampleQueue.pop_front(buf, ATRAC3PLUS_MAX_SAMPLES * sizeof(s16) * atrac->atracChannels);

View file

@ -413,7 +413,7 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) {
// Resample to the correct pitch, writing exactly "grainSize" samples. // Resample to the correct pitch, writing exactly "grainSize" samples.
u32 sampleFrac = voice.sampleFrac; u32 sampleFrac = voice.sampleFrac;
const int MAX_CONFIG_VOLUME = 17; // 12 + 5 const int MAX_CONFIG_VOLUME = 20;
int volumeShift = (MAX_CONFIG_VOLUME - g_Config.iSEVolume); int volumeShift = (MAX_CONFIG_VOLUME - g_Config.iSEVolume);
if (volumeShift < 0) volumeShift = 0; if (volumeShift < 0) volumeShift = 0;
for (int i = 0; i < grainSize; i++) { for (int i = 0; i < grainSize; i++) {

View file

@ -870,7 +870,7 @@ void AudioScreen::render() {
if (g_Config.iBGMVolume > 1) if (g_Config.iBGMVolume > 1)
g_Config.iBGMVolume -= 1; g_Config.iBGMVolume -= 1;
if (UIButton(GEN_ID, hlinear1, 50, 0, a->T("+1"), ALIGN_LEFT)) if (UIButton(GEN_ID, hlinear1, 50, 0, a->T("+1"), ALIGN_LEFT))
if (g_Config.iBGMVolume < 5) if (g_Config.iBGMVolume < 8)
g_Config.iBGMVolume += 1; g_Config.iBGMVolume += 1;
y+=20; y+=20;
char sevol[256]; char sevol[256];
@ -883,7 +883,7 @@ void AudioScreen::render() {
if (g_Config.iSEVolume > 1) if (g_Config.iSEVolume > 1)
g_Config.iSEVolume -= 1; g_Config.iSEVolume -= 1;
if (UIButton(GEN_ID, hlinear2, 50, 0, a->T("+1"), ALIGN_LEFT)) if (UIButton(GEN_ID, hlinear2, 50, 0, a->T("+1"), ALIGN_LEFT))
if (g_Config.iSEVolume < 5) if (g_Config.iSEVolume < 8)
g_Config.iSEVolume += 1; g_Config.iSEVolume += 1;
y+=10; y+=10;