Skip to content

Commit

Permalink
Merge pull request #2638 from bagnz0r/master
Browse files Browse the repository at this point in the history
Audio optimization, usability fixes, sound peak blowout fix, Polish translation, bugfixes
  • Loading branch information
hrydgard committed Jul 18, 2013
2 parents 086746e + 90d0f16 commit 05dfd27
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ void Config::Load(const char *iniFileName)
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
sound->Get("Enable", &bEnableSound, true);
sound->Get("EnableAtrac3plus", &bEnableAtrac3plus, true);
sound->Get("BGMVolume", &iBGMVolume, 4);
sound->Get("SEVolume", &iSEVolume, 4);
sound->Get("BGMVolume", &iBGMVolume, 5);
sound->Get("SEVolume", &iSEVolume, 5);

IniFile::Section *control = iniFile.GetOrCreateSection("Control");
control->Get("ShowStick", &bShowAnalogStick, false);
Expand Down
14 changes: 14 additions & 0 deletions Core/HLE/__sceAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "FixedSizeQueue.h"
#include "Common/Thread.h"

#define LOW_LATENCY_AUDIO false

// Should be used to lock anything related to the outAudioQueue.
recursive_mutex section;

Expand All @@ -37,15 +39,27 @@ int eventHostAudioUpdate = -1;
int mixFrequency = 44100;

const int hwSampleRate = 44100;

#ifdef LOW_LATENCY_AUDIO
const int hwBlockSize = 16;
const int hostAttemptBlockSize = 256;
#else
const int hwBlockSize = 64;
const int hostAttemptBlockSize = 512;
#endif;

const int audioIntervalUs = (int)(1000000ULL * hwBlockSize / hwSampleRate);
const int audioHostIntervalUs = (int)(1000000ULL * hostAttemptBlockSize / hwSampleRate);

// High and low watermarks, basically. For perfect emulation, the correct values are 0 and 1, respectively.
// TODO: Tweak
#ifdef LOW_LATENCY_AUDIO
const int chanQueueMaxSizeFactor = 0;
const int chanQueueMinSizeFactor = 1;
#else
const int chanQueueMaxSizeFactor = 2;
const int chanQueueMinSizeFactor = 1;
#endif

// TODO: Need to replace this with something lockless. Mutexes in the audio pipeline
// is bad mojo.
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceAtrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ u32 _AtracDecodeData(int atracID, u8* outbuf, u32 *SamplesNum, u32* finish, int
atrac->sampleQueue.push(buf, decodebytes);
}
}
const int MAX_CONFIG_VOLUME = 5;
const int MAX_CONFIG_VOLUME = 8;
s16* out = (s16*)outbuf;
memset(out, 0, ATRAC3PLUS_MAX_SAMPLES * sizeof(s16) * atrac->atracOutputChannels);
int gotsize = atrac->sampleQueue.pop_front(buf, ATRAC3PLUS_MAX_SAMPLES * sizeof(s16) * atrac->atracChannels);
Expand Down
2 changes: 1 addition & 1 deletion Core/HW/SasAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) {

// Resample to the correct pitch, writing exactly "grainSize" samples.
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);
if (volumeShift < 0) volumeShift = 0;
for (int i = 0; i < grainSize; i++) {
Expand Down
4 changes: 2 additions & 2 deletions UI/MenuScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ void AudioScreen::render() {
if (g_Config.iBGMVolume > 1)
g_Config.iBGMVolume -= 1;
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;
y+=20;
char sevol[256];
Expand All @@ -883,7 +883,7 @@ void AudioScreen::render() {
if (g_Config.iSEVolume > 1)
g_Config.iSEVolume -= 1;
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;

y+=10;
Expand Down

0 comments on commit 05dfd27

Please sign in to comment.