Fixed audio track seek truncation; scope supports higher rates for speech; bug 999

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2794 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2007-07-03 21:24:12 +00:00
parent 5205cb3444
commit fde47c9869
3 changed files with 14 additions and 4 deletions
+2
View File
@@ -1,4 +1,6 @@
Changes towards version 0.7:
- Fixed speech looping with long tracks at high sampling rates;
scope supports higher rates for speech now; bug 999 - Alex
- Basic support for .ani-based shipspin animations - Michael
- Fixed some Melnorme history info timestamps - Alex
- Fixed Ur-Quan story timestamps, from Vlad-Ceru Opran
@@ -403,7 +403,7 @@ SoundDecoder_Load (uio_DirHandle *dir, char *filename,
if (runTime > 0 && runTime / 1000.0 < decoder->length)
decoder->length = (float)(runTime / 1000.0);
decoder->start_sample = decoder->frequency * startTime / 1000;
decoder->start_sample = (uint32)(startTime / 1000.0f * decoder->frequency);
decoder->end_sample = decoder->start_sample +
(unsigned long)(decoder->length * decoder->frequency);
if (decoder->start_sample != 0)
@@ -606,7 +606,7 @@ SoundDecoder_Seek (TFB_SoundDecoder *decoder, uint32 seekTime)
return;
}
pcm_pos = seekTime * decoder->frequency / 1000;
pcm_pos = (uint32) (seekTime / 1000.0f * decoder->frequency);
pcm_pos = decoder->funcs->Seek (decoder,
decoder->start_sample + pcm_pos);
decoder->pos = pcm_pos * decoder->bytes_per_samp;
+10 -2
View File
@@ -825,6 +825,7 @@ FastForward_Page ()
int
GetSoundData (void *data)
{
// XXX: These two variants are begging to be merged
if (speechVolumeScale != 0.0f)
{
// speech is enabled
@@ -840,12 +841,18 @@ GetSoundData (void *data)
sample->decoder->frequency * 2.0f);
unsigned long pos;
int i;
int step;
UBYTE *scopedata = (UBYTE *) data;
UBYTE *sbuffer = soundSource[SPEECH_SOURCE].sbuffer;
assert (soundSource[SPEECH_SOURCE].sample->decoder->frequency == 11025);
assert (soundSource[SPEECH_SOURCE].sample->decoder->frequency >= 11025);
assert (soundSource[SPEECH_SOURCE].sample->decoder->format == audio_FORMAT_MONO16);
// Using step of 1 sample at 11025Hz, because the human speech
// is mostly in the low frequencies
step = soundSource[MUSIC_SOURCE].sample->decoder->frequency * 2 / 11025;
step = (step + 1) & ~1;
if (delta < 0)
{
log_add (log_Debug, "GetSoundData(): something's messed"
@@ -892,7 +899,7 @@ GetSoundData (void *data)
s = RADAR_HEIGHT - 2;
scopedata[i] = (UBYTE) s;
pos += 2;
pos += step;
}
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
@@ -921,6 +928,7 @@ GetSoundData (void *data)
assert (soundSource[MUSIC_SOURCE].sample->decoder->frequency >= 11025);
assert (soundSource[MUSIC_SOURCE].sample->decoder->format == audio_FORMAT_STEREO16);
// Using step of 4 samples at 11025Hz for the music
step = soundSource[MUSIC_SOURCE].sample->decoder->frequency / 11025 * 16;
if (step % 2 == 1)
step++;