View Single Post
  #4  
Old 22nd April 2013, 09:19 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,256
Default

Been catching up on posts, just still trying to move so cannot participate fully.

A small fragment within the audio.cpp
Code:
    switch (SystemType) 
    {
        case SYSTEM_NTSC:
            g_DxSoundContext.Frequency = 48681812 / g_DxSoundContext.Dacrate; 
            break;

        case SYSTEM_PAL:  
            g_DxSoundContext.Frequency = 49656530 / g_DxSoundContext.Dacrate; 
            break;

        case SYSTEM_MPAL: 
            g_DxSoundContext.Frequency = 48628316 / g_DxSoundContext.Dacrate; 
            break;

        default:
            g_DxSoundContext.Frequency = 48681812 / g_DxSoundContext.Dacrate; 
            break;
    }
NTSC is sort of like the default, but if a ROM hard-set an invalid audio system (SystemType > 0x00000002) then I would personally want to debug it with a warning alert notifying that the game is weird and could prove useful for research.

Code:
const long int FreqTable[3] = {
    48681812, /* SYSTEM_NTSC */
    49656530, /* SYSTEM_PAL */
    48628316  /* SYSTEM_MPAL */
};

/* ... stuff in-between */
EXPORT void CALL AiDacrateChanged(int SystemType)
{
/* ... more stuff */
    if (SystemType > 2)
    {
        DebugPrintf("Invalid SystemType\n");
        SystemType = SYSTEM_NTSC; /* default value? (Suanyuan) */
    }
    g_DxSoundContext.Frequency = FreqTable[SystemType] / g_DxSoundContext.Dacrate;
/* ... */
}
But yeah, not really that important.
The DAC rate and the SystemType audio clocks are what causes the un-rounded audio frequencies (~32,006 Hz instead of exactly 32 KHz for Mario64, etc.) in Jabo's and everyone else's audio plugins. I wrote a sort of "fix" for this but it could just be a hack.