-Added support for Master volume

This commit is contained in:
cyberwarriorx 2006-11-22 21:24:54 +00:00
parent 3e916e190a
commit 97b68cc3be
1 changed files with 6 additions and 2 deletions

View File

@ -147,8 +147,6 @@ int SPU_Init(int coreid, int buffersize)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void SPU_Pause(int pause) void SPU_Pause(int pause)
{ {
if(pause) if(pause)
@ -1084,6 +1082,7 @@ void (*SPU_ChanUpdate[4][3])(channel_struct *chan) = {
void SPU_MixAudio(int length) void SPU_MixAudio(int length)
{ {
channel_struct *chan; channel_struct *chan;
u8 vol;
int i; int i;
memset(SPU->sndbuf, 0, length*4*2); memset(SPU->sndbuf, 0, length*4*2);
@ -1092,6 +1091,8 @@ void SPU_MixAudio(int length)
if (!(MMU.ARM7_REG[0x501] & 0x80)) if (!(MMU.ARM7_REG[0x501] & 0x80))
return; return;
vol = MMU.ARM7_REG[0x500] & 0x7F;
for(chan = &(SPU->chan[0]); chan < &(SPU->chan[16]); chan++) for(chan = &(SPU->chan[0]); chan < &(SPU->chan[16]); chan++)
{ {
if (chan->status != CHANSTAT_PLAY) if (chan->status != CHANSTAT_PLAY)
@ -1112,6 +1113,9 @@ void SPU_MixAudio(int length)
// convert from 32-bit->16-bit // convert from 32-bit->16-bit
for (i = 0; i < length*2; i++) for (i = 0; i < length*2; i++)
{ {
// Apply Master Volume
SPU->sndbuf[i] = SPU->sndbuf[i] * vol / 127;
if (SPU->sndbuf[i] > 0x7FFF) if (SPU->sndbuf[i] > 0x7FFF)
SPU->outbuf[i] = 0x7FFF; SPU->outbuf[i] = 0x7FFF;
else if (SPU->sndbuf[i] < -0x8000) else if (SPU->sndbuf[i] < -0x8000)