Code: Select all
One second
|--------------------------|
############################ 32040 samples
[][][][][][][][][][][][][][] 60.09 frames
Code: Select all
## 533.2 samples
[] 1 frame
Code: Select all
One second
|--------------------------|
############################ 48000 samples
[][][][][][][][][][][][][][] 60 frames
Code: Select all
## 800 samples
[] 1 frame
Now, there's the issue of the PC not being exactly what it claims. Let's say the display really runs at 59.9 frames per second. This means that we need to generate 48000/59.9 = 801.3 samples per frame. Another example, if the sound card actually runs at 47987 samples per second, then we need to generate 47987/60 = 799.8 samples per frame. The user might not know these exact values, so he can adjust the samples per frame until he doesn't get gaps in audio (too few per frame) and video frames displayed for twice as long (too many samples per frame) are at a minimum.
What comes from this is that deviations of the PC's display rate or sound card rate can both be compensated for by adjusting how many samples we generate per frame. All the user has to do is adjust the value. There are a few ways to do so. The user could be presented with the number of samples per frame, and adjust that, or he could simply adjust a percentage that is applied to the ideal value. For example, he could tell it to use 98% of the ideal value (800*0.98 = 784 samples), or 102% (800*1.02 = 816 samples). The percentage seems more user-friendly, since it's not exposing irrelevant internal details, and it probably would apply even if the sound card rate were changed (for example from 48000 to 44100), since deviations are probably due to the clock crystal rather than peculiar to a particular rate.
What should the "samples per frame" control be labeled? Fundamentally it's causing sound to run faster or slower, without affecting video rate. The more samples per frame, the lower the sound pitch. So 102% would lower pitch since it stretches things out more. Maybe the slider could simply be labeled
Code: Select all
A/V sync: Smoother video, [-----------O------------] Jumpy video,
audio crackling clean audio
SNES: 32040 samples per second, 60.09 frames per second = 533.2 samples per frame
PC: 48000 samples per second, 60 frames per second = 800 samples per frame
User adjustment: 800 samples per frame * value close to 1.0
Resampler: For every 533.2 input samples, output 800*adjust samples. Simple.