diff --git a/sc2/content/comm/melnorm/melnorm.txt b/sc2/content/comm/melnorm/melnorm.txt index b66a89d68..2a8ac59ae 100755 --- a/sc2/content/comm/melnorm/melnorm.txt +++ b/sc2/content/comm/melnorm/melnorm.txt @@ -536,7 +536,7 @@ In exchange, we will give you #(SOLD_RAINBOW_LOCATIONS3) melno204.ogg Credits. - + #(sell_precursor_find) We found a Precursor artifact. Do you want it? diff --git a/sc2/src/sc2code/libs/sound/decoders/decoder.c b/sc2/src/sc2code/libs/sound/decoders/decoder.c index cbda98835..2e02c7ae3 100644 --- a/sc2/src/sc2code/libs/sound/decoders/decoder.c +++ b/sc2/src/sc2code/libs/sound/decoders/decoder.c @@ -659,22 +659,30 @@ void SoundDecoder_Seek (TFB_SoundDecoder *decoder, uint32 seekTime) else decoder->pos = (pcm_pos + decoder->start_sample) * 4; - //fprintf (stderr, "SoundDecoder_Seek(): seek %s\n", decoder->filename); + //fprintf (stderr, "SoundDecoder_Seek(): %s (start: %d pos: %d end: %d)\n", + // decoder->filename, decoder->start_sample, pcm_pos, decoder->end_sample); decoder->error = SOUNDDECODER_OK; return; } case SOUNDDECODER_BUF: { - decoder->pos = seekTime * decoder->frequency * - (decoder->format == decoder_formats.mono16 ? 2 : 4) / 1000; + uint32 pcm_pos = seekTime * decoder->frequency / 1000; + decoder->pos = pcm_pos * + (decoder->format == decoder_formats.mono16 ? 2 : 4); + //fprintf (stderr, "SoundDecoder_Seek(): %s(buf) (start: %d pos: %d end: %d)\n", + // decoder->filename, decoder->start_sample, pcm_pos, decoder->end_sample); decoder->error = SOUNDDECODER_OK; return; } case SOUNDDECODER_NULL: - decoder->pos = seekTime * decoder->frequency * 2 / 1000; + { + uint32 pcm_pos = seekTime * decoder->frequency / 1000; + decoder->pos = pcm_pos * 2; + //fprintf (stderr, "SoundDecoder_Seek(): %s(null) (start: %d pos: %d end: %d)\n", + // decoder->filename, decoder->start_sample, pcm_pos, decoder->end_sample); decoder->error = SOUNDDECODER_OK; return; - + } default: { fprintf (stderr, "SoundDecoder_Seek(): unknown type %d\n", decoder->type); diff --git a/sc2/src/sc2code/libs/sound/trackplayer.c b/sc2/src/sc2code/libs/sound/trackplayer.c index 003f89e84..d4d3b76cc 100644 --- a/sc2/src/sc2code/libs/sound/trackplayer.c +++ b/sc2/src/sc2code/libs/sound/trackplayer.c @@ -185,7 +185,7 @@ DoTrackTag (TFB_SoundTag *tag) } } -void +int GetTimeStamps(UNICODE *TimeStamps, sint32 *time_stamps) { int pos; @@ -207,6 +207,7 @@ GetTimeStamps(UNICODE *TimeStamps, sint32 *time_stamps) if (*TimeStamps) TimeStamps++; } + return (num); } #define TEXT_SPEED 70 @@ -413,11 +414,13 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, void (* } else tct++; - if (TimeStamp) - GetTimeStamps (TimeStamp, time_stamps); fprintf (stderr, "SpliceTrack(): loading %s\n", TrackName); + if (TimeStamp) + if ((GetTimeStamps (TimeStamp, time_stamps) + 1) != num_pages) + fprintf (stderr, "SpliceTrack(): number of timestamps doesn't match number of pages!\n"); + startTime = 0; for (page_counter = 0; page_counter < num_pages; page_counter++) { @@ -446,7 +449,7 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, void (* } startTime += abs (time_stamps[page_counter]); - // fprintf (stderr, "page (%d of %d): %d\n",page_counter, num_pages, startTime); + // fprintf (stderr, "page (%d of %d): %d ts: %d\n",page_counter, num_pages, startTime, time_stamps[page_counter]); if (last_chain->decoder) { //fprintf (stderr, " decoder: %s, rate %d format %x\n", @@ -500,7 +503,11 @@ recompute_track_pos (TFB_SoundSample *sample, TFB_SoundChain *first_chain, sint3 return; while (cur_chain->next && (sint32)(cur_chain->next->start_time * (float)ONE_SECOND) < offset) + { + if (cur_chain->tag.type) + DoTrackTag (&cur_chain->tag); cur_chain = cur_chain->next; + } if (cur_chain->tag.type) DoTrackTag (&cur_chain->tag); if ((sint32)((cur_chain->start_time + cur_chain->decoder->length) * (float)ONE_SECOND) < offset)