Fix SetPositionSamples() when we have a rate. This should fix
the editor problems. There's a major restriction of rate changing: you can't change the rate while the song is playing. That's because RageSound keeps track of the number of samples actually *output to the sound driver*; it determines the position within the sound by dividing by the rate. (It might be possible to adjust position dynamically within SetPlaybackRate to make this work, but this isn't done right now.)
This commit is contained in:
@@ -709,6 +709,15 @@ bool RageSound::SetPositionSamples( int samples )
|
||||
if(!playing)
|
||||
L.Unlock();
|
||||
|
||||
/* If we're seeking to sample 10, and the playback rate is 0.5, we really
|
||||
* want to seek to sample 20; it'll be multiplied back out in GetPosition.
|
||||
* (The reason for this is to keep "position" in 44100 samples/second, so
|
||||
* sound drivers don't have to know about the playback rate.) Think of
|
||||
* it this way: if we seek to sample 10 in the input file, and we're playing
|
||||
* it half speed, we would have actually played 20 samples, not 10, and
|
||||
* it's the number of real speaker samples that "position" represents. */
|
||||
samples = int(samples / GetPlaybackRate());
|
||||
|
||||
/* If we're already there, don't do anything. */
|
||||
if(position == samples)
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user