SNESMusic.org Forums
http://snesmusic.jukor.net/

Removing the phase inversion effect from SPCs?
http://snesmusic.jukor.net/viewtopic.php?f=25&t=1788
Page 1 of 1

Author:  anosci [ Wed Mar 14, 2018 6:07 pm ]
Post subject:  Removing the phase inversion effect from SPCs?

hi!

some snes games feature soundtracks that have a very distinct effect. in tracker terms, I've seen it called "surround mode"

it sounds like this:
https://www.youtube.com/watch?v=xJF19947zcQ

or, if your mixing the song to a mono output, it sounds like this:
https://www.youtube.com/watch?v=g4mHPeMGTJM

it's really annoying!

I looked into it, and this is possible because every channel has a different volume level for left and right output...and that value is a signed number.
if the signs are flipped, the phase is completely inverted and you get that "surround" effect.

so...if I want to remove that effect, I just need to make sure that the volume registers are all positive.
which means I only need to change 1 bit in 16 places. EZ right?
except nope the SPC format doesn't work like that.

I've tried digging around for a tool that does this, but have had no luck.

is there an option in snesamp that I missed that will solve this for me?

Do I need to build a copy of snesamp for myself?

Author:  KungFuFurby [ Tue Mar 20, 2018 3:15 pm ]
Post subject:  Re: Removing the phase inversion effect from SPCs?

This is sound driver-dependent... but if you were to not hack every single SPC, then you would AND the volume values by 0x7F.

Author:  anosci [ Thu Mar 22, 2018 11:59 pm ]
Post subject:  Re: Removing the phase inversion effect from SPCs?

so....rebuild snesamp.

I actually had some success with this:

https://www.alpha-ii.com/Source/index.html

despite all of the weirdness, I'm able to get a compiled version of SNESAPU.DLL, which I can safely swap out with whatever instance of SNESAmp I want.

the issue is that all of the emulation code is written in x86 Assembly, which I can not make heads or tails of. I know what to change but I have no idea where.

any advice?

Author:  anosci [ Sun Mar 25, 2018 9:54 pm ]
Post subject:  Re: Removing the phase inversion effect from SPCs?

ISSUE RESOLVED

Instead of dealing with a byte mask for the APU registers, I just applied an absolute value function to all of the voices as they were being mixed down. (in the floating point block of code)

here's the link to the source again: https://www.alpha-ii.com/Source/index.html

in DSP.Asm scroll down to line 5757 or so, then make these two changes:

Code:
Test    byte [EBX+mFlg],MFLG_MUTE
JNZ .VoiceOldCode
;Apply channel volumes ---------- NEW VER
FLd  ST
FLDZ
FAdd dword [EBX+mChnR]
FABS
FMulP ST1, ST
;second half
FXCh ST1
FLDZ
FAdd dword [EBX+mChnL]
FABS
FMulP ST1, ST
;end
Jmp .VoiceSignBlockEnd

.VoiceOldCode:
;Apply channel volumes ----------
FLd ST
FMul    dword [EBX+mChnR]
FXCh    ST1
FMul    dword [EBX+mChnL]
.VoiceSignBlockEnd:

and further down, just fix the entire master volume. if you want to set it back to "surround" there's an option in SNESAmp for that
Code:
;Multiply samples by main volume ------ NEW VER
FLd dword [ESI]
FLDZ
FAdd dword [volMainL]
FABS
FMulP   ST1,ST
FStP    dword [EDI]
;second half
FLd dword [4+ESI]
FLDZ
FAdd dword [volMainR]
FABS
FMulP   ST1,ST
FStP    dword [4+EDI]

(hopefully it's obvious where these go)

compile that and put the new DLL in the same directory as your SNESAmp plugin, and you're good to go.

Set the mixing to "Stereo" for normal/"accurate" mixing, and the nset it to "Stereo(HQ)" for when you want all the "surround" stuff disabled. (with the ability to re-enable them via channel muting)

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/