GetStreamToSourceRatio. This will allow RateChange() to
be implemented with a filter, instead of being built into
RageSound, allow filters that change the music rate while
preserving robust correlation to the original audio.
This tightens up the frame definitions, resulting in three
frame counters:
- source frames; frames into the original source audio
- stream frames; frame counter after all filtering
- hardware frames; the sound driver's frame counter
All frames are in the sample rate of the stream; if audio
is resampled to match the hardware, the resampled audio is
considered the source audio, and frame units are in the
resulting sample rate.
By design, source frames are never exposed to the sound
driver, which only deals with stream and hardware frames.
The principle of the ratio API is that while a filter stream
should ideally output audio at the exact rate it advertises
through GetStreamToSourceRatio, rounding error will inevitably
creep in. Rather than depending on the ratio being exact
over an arbitrary length of time, each filter's GetNextSourceFrame
calculates the actual next source frame. Typically, it
will be equal to (its value before the previous read) + (number
of frames read * previous ratio). This avoids hard-to-debug
synchronization drift.
(This also eliminates the 1k buffer which was used for crappy
rate changing, which can be readded with a buffer filter if
needed. Rate changing is disabled for a while until a bit
more work is done.)
comments fell behind the code. In this case, it's better to use a better
name than "iSize" which indicates units, eg. "iBytes" or "iFrames", than
to explain the units in a comment.
muted sounds when GetPlayOnlyCriticalSounds changes. Fixes background music
playing for a split second in some sound drivers when start is pressed during attract.