diff options
| author | hrydgard <hrydgard@gmail.com> | 2009-07-01 22:26:01 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2009-07-01 22:26:01 +0000 |
| commit | 0008d5ef77983c4b7bfa4fde4401fb5ea1e6535c (patch) | |
| tree | 38ba82b71743a6dde55f2bcb2fb4d387c382be7e /Source | |
| parent | f6af7794cd91f6a78241c4988ee6521ee14679b4 (diff) | |
DSPHLE: Preserve fractional sample position between voice render calls. sounds slightly, slightly cleaner :P
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3637 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
3 files changed, 33 insertions, 19 deletions
diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h index 69a8bfbe9f..80a40f2e1c 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h @@ -30,8 +30,8 @@ struct ZeldaVoicePB { // Read-Write part u16 Status; // 0x00 | 1 = play, 0 = stop - u16 KeyOff; // 0x01 | writing 1 stops voice? - u16 RatioInt; // 0x02 | delta? ratio? integer part + u16 KeyOff; // 0x01 | writing 1 stops voice? + u16 RatioInt; // 0x02 | Position delta (playback speed) u16 Unk03; // 0x03 | unknown u16 NeedsReset; // 0x04 | indicates if some values in PB need to be reset u16 ReachedEnd; // 0x05 | set to 1 when end reached @@ -43,7 +43,13 @@ struct ZeldaVoicePB u16 Unk0B[2]; // 0x0B | unknown u16 volumeRight1; // 0x0D | Right Volume 1 u16 volumeRight2; // 0x0E | Right Volume 2 - u16 Unk0F[0x8]; // 0x0F | unknown // Buffer / something, see 036e/ZWW. there's a pattern here + u16 Unk0F[2]; // 0x0F | unknown // Buffer / something, see 036e/ZWW. there's a pattern here + u16 volumeUnknown1_1; // 0x11 | Unknown Volume 1 + u16 volumeUnknown1_2; // 0x12 | Unknown Volume 1 + u16 Unk13[2]; // 0x13 | unknown + u16 volumeUnknown2_1; // 0x15 | Unknown Volume 2 + u16 volumeUnknown2_2; // 0x16 | Unknown Volume 2 + u16 Unk17; // 0x17 | unknown u16 Unk18[0x10]; // 0x18 | unknown u16 Unk28; // 0x28 | unknown u16 Unk29; // 0x29 | unknown // multiplied by 0x2a @ 0d21/ZWW @@ -53,7 +59,7 @@ struct ZeldaVoicePB u16 Unk2D; // 0x2D | unknown u16 Unk2E; // 0x2E | unknown u16 Unk2F; // 0x2F | unknown - u16 RatioFrac; // 0x30 | ??? ratio fractional part + u16 CurSampleFrac; // 0x30 | Fractional part of the current sample position u16 Unk31; // 0x31 | unknown / unused u16 CurBlock; // 0x32 | current block? u16 FixedSample; // 0x33 | sample value for "blank" voices diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Synth.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Synth.cpp index 721b3e9269..2501b29159 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Synth.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Synth.cpp @@ -26,8 +26,9 @@ void CUCode_Zelda::RenderSynth_Waveform(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
{
float ratioFactor = 32000.0f / (float)soundStream->GetMixer()->GetSampleRate();
- u32 _ratio = (((PB.RatioInt * 80) + PB.RatioFrac) << 4) & 0xFFFF0000;
- u64 ratio = (u64)(((_ratio / 80) << 16) * ratioFactor);
+ u32 _ratio = (PB.RatioInt << 16);
+ s64 ratio = (_ratio * ratioFactor) * 16;
+
int mask = PB.Format ? 3 : 1, shift = PB.Format ? 2 : 1;
u32 pos[2] = {0, 0};
diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp index e957d5a29d..3c4f1beb74 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp @@ -57,7 +57,7 @@ void CUCode_Zelda::WritebackVoicePB(u32 _Addr, ZeldaVoicePB& PB) void CUCode_Zelda::RenderVoice_PCM16(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
{
float ratioFactor = 32000.0f / (float)soundStream->GetMixer()->GetSampleRate();
- u32 _ratio = (((PB.RatioInt * 80) + PB.RatioFrac) << 4) & 0xFFFF0000;
+ u32 _ratio = (((PB.RatioInt * 80) + PB.CurSampleFrac) << 4) & 0xFFFF0000;
u64 ratio = (u64)(((_ratio / 80) << 16) * ratioFactor);
u32 pos[2] = {0, 0};
@@ -129,7 +129,7 @@ _lRestart: void CUCode_Zelda::RenderVoice_AFC(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
{
float ratioFactor = 32000.0f / (float)soundStream->GetMixer()->GetSampleRate();
- u32 _ratio = (PB.RatioInt<<16) + PB.RatioFrac;
+ u32 _ratio = (PB.RatioInt << 16);// + PB.RatioFrac;
s64 ratio = (_ratio * ratioFactor) * 16; // (s64)(((_ratio / 80) << 16) * ratioFactor);
// initialize "decoder" if the sample is played the first time
@@ -151,17 +151,23 @@ void CUCode_Zelda::RenderVoice_AFC(ZeldaVoicePB &PB, s32* _Buffer, int _Size) // Copy ARAM addr from r to rw area.
PB.CurAddr = PB.StartAddr;
PB.ReachedEnd = 0;
-
+ PB.CurSampleFrac = 0;
// Looking at Zelda Four Swords
// WARN_LOG(DSPHLE, "PB -----: %04x", PB.Unk03);
// WARN_LOG(DSPHLE, "PB Unk03: %04x", PB.Unk03); 0
// WARN_LOG(DSPHLE, "PB Unk07: %04x", PB.Unk07[0]); 0
- //WARN_LOG(DSPHLE, "PB Unk09: %04x", PB.volumeLeft1); // often same value as 0a
- //WARN_LOG(DSPHLE, "PB Unk0a: %04x", PB.volumeLeft2);
+ WARN_LOG(DSPHLE, "PB Unk09: %04x", PB.volumeLeft1); // often same value as 0a
+ WARN_LOG(DSPHLE, "PB Unk0a: %04x", PB.volumeLeft2);
+
+ WARN_LOG(DSPHLE, "PB Unk0d: %04x", PB.volumeRight1); // often same value as 0e
+ WARN_LOG(DSPHLE, "PB Unk0e: %04x", PB.volumeRight2);
- //WARN_LOG(DSPHLE, "PB Unk0d: %04x", PB.volumeRight1); // often same value as 0e
- //WARN_LOG(DSPHLE, "PB Unk0e: %04x", PB.volumeRight2);
+ WARN_LOG(DSPHLE, "PB UnkVol11: %04x", PB.volumeUnknown1_1);
+ WARN_LOG(DSPHLE, "PB UnkVol12: %04x", PB.volumeUnknown1_2);
+
+ WARN_LOG(DSPHLE, "PB UnkVol21: %04x", PB.volumeUnknown2_1);
+ WARN_LOG(DSPHLE, "PB UnkVol22: %04x", PB.volumeUnknown2_2);
/// WARN_LOG(DSPHLE, "PB Unk78: %04x", PB.Unk78);
// WARN_LOG(DSPHLE, "PB Unk79: %04x", PB.Unk79);
@@ -222,18 +228,19 @@ restart: AFCdecodebuffer(m_AFCCoefTable, (char*)(source + (PB.CurAddr & ram_mask)), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, PB.Format);
PB.CurAddr += 9;
- s64 TrueSamplePosition = (s64)(PB.Length - PB.RemLength) << 32;
- s64 delta = ratio; // 0x100000000ULL;
+ s64 TrueSamplePosition = (s64)(PB.Length - PB.RemLength) << 16;
+ TrueSamplePosition += PB.CurSampleFrac;
+ s64 delta = ratio >> 16; // 0x100000000ULL;
int sampleCount = 0;
while (sampleCount < _Size)
{
- int SamplePosition = TrueSamplePosition >> 32;
+ int SamplePosition = TrueSamplePosition >> 16;
_Buffer[sampleCount] = outbuf[SamplePosition & 15];
sampleCount++;
TrueSamplePosition += delta;
- int TargetPosition = TrueSamplePosition >> 32;
+ int TargetPosition = TrueSamplePosition >> 16;
// Decode forwards...
while (SamplePosition < TargetPosition)
@@ -267,7 +274,7 @@ restart: // }
PB.NeedsReset = 0;
-
+ PB.CurSampleFrac = TrueSamplePosition & 0xFFFF;
// write back
// NumberOfSamples = (NumberOfSamples << 4) | frac; // missing fraction
@@ -315,7 +322,7 @@ void CUCode_Zelda::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _Righ WARN_LOG(DSPHLE, "5 byte AFC - does it work?");
case 0x0009: // AFC with normal bitrate (32:9 compression).
- // Use this to disable music (GREAT for testing)
+ // XK: Use this to disable music (GREAT for testing)
//if(PB.SoundType == 0x0d00)
// break;
|
