Improved wav duration calculation - now supports sample rates other than 11025.

Bumped build tool version to VS2019.
This commit is contained in:
Muzychenko Andrey committed 2021-08-18 12:44:26 +03:00
1 parent dcd488c48c
commit d5b44e44e1
5 files changed
+48 -11

No files matched your search

+5 -2
View File
@@ -135,6 +135,8 @@ int loader::get_sound_id(int groupIndex)
if (!sound_list[soundIndex].Loaded && !sound_list[soundIndex].WavePtr)
{
WaveHeader wavHeader{};
int soundGroupId = sound_list[soundIndex].GroupIndex;
sound_list[soundIndex].Duration = 0.0;
if (soundGroupId > 0 && !pinball::quickFlag)
@@ -150,9 +152,10 @@ int loader::get_sound_id(int groupIndex)
pinball::make_path_name(filePath, fileName2);
HFILE hFile = _lopen(filePath, 0);
sound_list[soundIndex].Duration = static_cast<float>(static_cast<double>(_llseek(hFile, 0, SEEK_END)) *
0.0000909090909090909);
_lread(hFile, &wavHeader, sizeof wavHeader);
_lclose(hFile);
auto sampleCount = wavHeader.data_size / (wavHeader.channels * (wavHeader.bits_per_sample / 8.0));
sound_list[soundIndex].Duration = static_cast<float>(sampleCount / wavHeader.sample_rate);
sound_list[soundIndex].WavePtr = Sound::LoadWaveFile(filePath);
}
}