Respect the bgm vol setting for at3, mp3, video.

This commit is contained in:
Unknown W. Brackets 2013-10-26 19:20:44 -07:00
parent d3f2d71d4b
commit ad8c4af936
7 changed files with 23 additions and 4 deletions

View File

@ -24,6 +24,8 @@
extern const char *PPSSPP_GIT_VERSION;
const int MAX_CONFIG_VOLUME = 8;
struct Config {
public:
Config();

View File

@ -69,8 +69,6 @@ const u32 ATRAC3PLUS_MAX_SAMPLES = 0x800;
static const int atracDecodeDelay = 2300;
static const int MAX_CONFIG_VOLUME = 8;
#ifdef USE_FFMPEG
extern "C" {
@ -626,6 +624,7 @@ u32 _AtracDecodeData(int atracID, u8* outbuf, u32 *SamplesNum, u32* finish, int
if (avret < 0) {
ERROR_LOG(ME, "swr_convert: Error while converting %d", avret);
}
__AdjustBGMVolume((s16 *)out, numSamples * atrac->pFrame->channels);
}
}
av_free_packet(&packet);
@ -1693,6 +1692,7 @@ int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesConsumedA
if (avret < 0) {
ERROR_LOG(ME, "swr_convert: Error while converting %d", avret);
}
__AdjustBGMVolume((s16 *)out, numSamples * atrac->pFrame->channels);
}
av_free_packet(&packet);
if (got_frame)

View File

@ -18,6 +18,7 @@
#include <map>
#include <algorithm>
#include "Core/Config.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/sceMp3.h"
#include "Core/HW/MediaEngine.h"
@ -211,6 +212,7 @@ int sceMp3Decode(u32 mp3, u32 outPcmPtr) {
ERROR_LOG(ME, "swr_convert: Error while converting %d", ret);
return -1;
}
__AdjustBGMVolume((s16 *)out, frame.nb_samples * frame.channels);
//av_samples_copy(&audio_dst_data, frame.data, 0, 0, frame.nb_samples, frame.channels, (AVSampleFormat)frame.format);

View File

@ -15,6 +15,7 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "Core/Config.h"
#include "Core/HW/MediaEngine.h"
#include "Core/MemMap.h"
#include "Core/Reporting.h"
@ -113,6 +114,17 @@ bool InitFFmpeg() {
return true;
}
void __AdjustBGMVolume(s16 *samples, u32 count) {
if (g_Config.iBGMVolume < 0 || g_Config.iBGMVolume >= MAX_CONFIG_VOLUME) {
return;
}
int volumeShift = MAX_CONFIG_VOLUME - g_Config.iBGMVolume;
for (u32 i = 0; i < count; ++i) {
samples[i] >>= volumeShift;
}
}
MediaEngine::MediaEngine(): m_pdata(0) {
m_pFormatCtx = 0;
m_pCodecCtx = 0;

View File

@ -45,6 +45,8 @@ inline s64 getMpegTimeStamp(u8* buf) {
bool InitFFmpeg();
void __AdjustBGMVolume(s16 *samples, u32 count);
class MediaEngine
{
public:

View File

@ -424,8 +424,8 @@ void SasInstance::MixVoice(SasVoice &voice) {
// TODO: Special case no-resample case (and 2x and 0.5x) for speed, it's not uncommon
u32 sampleFrac = voice.sampleFrac;
const int MAX_CONFIG_VOLUME = 20;
int volumeShift = (MAX_CONFIG_VOLUME - g_Config.iSFXVolume);
// We need to shift by 12 anyway, so combine that with the volume shift.
int volumeShift = (12 + MAX_CONFIG_VOLUME - g_Config.iSFXVolume);
if (volumeShift < 0) volumeShift = 0;
for (int i = 0; i < grainSize; i++) {
// For now: nearest neighbour, not even using the resample history at all.

View File

@ -142,6 +142,7 @@ bool SimpleAT3::Decode(void* inbuf, int inbytes, uint8_t *outbuf, int *outbytes)
ERROR_LOG(ME, "swr_convert: Error while converting %d", swrRet);
return false;
}
__AdjustBGMVolume((s16 *)outbuf, numSamples * frame_->channels);
}
return true;