mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-20 08:21:08 +00:00
Merge pull request #992 from 0lvin/oggsizefix
Fix sound characteristics calculations
This commit is contained in:
commit
eaab2cf11a
2 changed files with 11 additions and 8 deletions
|
@ -739,23 +739,26 @@ OGG_LoadAsWav(char *filename, wavinfo_t *info, void **buffer)
|
|||
info->channels = ogg2wav_file->channels;
|
||||
info->loopstart = -1;
|
||||
/* return length * channels */
|
||||
info->samples = stb_vorbis_stream_length_in_samples(ogg2wav_file) / ogg2wav_file->channels;
|
||||
info->samples = stb_vorbis_stream_length_in_samples(ogg2wav_file) * info->channels;
|
||||
info->dataofs = 0;
|
||||
|
||||
/* alloc memory for uncompressed wav */
|
||||
final_buffer = Z_Malloc(info->samples * sizeof(short) * ogg2wav_file->channels);
|
||||
final_buffer = Z_Malloc(info->samples * sizeof(short));
|
||||
|
||||
/* load sampleas to buffer */
|
||||
read_samples = stb_vorbis_get_samples_short_interleaved(
|
||||
ogg2wav_file, info->channels, final_buffer,
|
||||
info->samples * ogg2wav_file->channels);
|
||||
info->samples);
|
||||
|
||||
if (read_samples > 0)
|
||||
{
|
||||
/* fix sample list size*/
|
||||
if (read_samples < info->samples)
|
||||
if ((read_samples * info->channels) != info->samples)
|
||||
{
|
||||
info->samples = read_samples;
|
||||
Com_DPrintf("%s: incorrect size: %d != %d\n",
|
||||
filename, info->samples, read_samples * info->channels);
|
||||
|
||||
info->samples = read_samples * info->channels;
|
||||
}
|
||||
|
||||
/* copy to final result */
|
||||
|
@ -772,7 +775,7 @@ OGG_LoadAsWav(char *filename, wavinfo_t *info, void **buffer)
|
|||
|
||||
if (ogg2wav_file)
|
||||
{
|
||||
stb_vorbis_close(ogg2wav_file);
|
||||
stb_vorbis_close(ogg2wav_file);
|
||||
}
|
||||
|
||||
FS_FreeFile(temp_buffer);
|
||||
|
|
|
@ -525,10 +525,10 @@ S_LoadSound(sfx_t *s)
|
|||
s->is_silenced_muzzle_flash = true;
|
||||
}
|
||||
|
||||
S_GetVolume(data + info.dataofs, info.samples * info.channels,
|
||||
S_GetVolume(data + info.dataofs, info.samples,
|
||||
info.width, &sound_volume);
|
||||
|
||||
S_GetStatistics(data + info.dataofs, info.samples * info.channels,
|
||||
S_GetStatistics(data + info.dataofs, info.samples,
|
||||
info.width, info.channels, sound_volume, &begin_length, &end_length,
|
||||
&attack_length, &fade_length);
|
||||
|
||||
|
|
Loading…
Reference in a new issue