mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-14 19:25:18 -05:00
parent
dae824ab75
commit
7f3bee15f0
2 changed files with 14 additions and 6 deletions
|
@ -465,6 +465,8 @@ int TPinballTable::Message(int code, float value)
|
|||
Sound::Idle();
|
||||
LightGroup->Message(28, 0.2f);
|
||||
auto time = loader::play_sound(SoundIndex1);
|
||||
if (time < 0)
|
||||
time = 5.0f;
|
||||
LightShowTimer = timer::set(time, this, LightShow_timeout);
|
||||
}
|
||||
|
||||
|
|
|
@ -94,8 +94,7 @@ void loader::loadfrom(datFileStruct* datFile)
|
|||
{
|
||||
if (sound_count < 65)
|
||||
{
|
||||
sound_list[sound_count].WavePtr = nullptr;
|
||||
sound_list[sound_count].GroupIndex = groupIndex;
|
||||
sound_list[sound_count] = {nullptr, groupIndex, 0, 0, nullptr};
|
||||
sound_count++;
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +110,7 @@ void loader::unload()
|
|||
|
||||
if (sound_list[index].PtrToSmth)
|
||||
memory::free(sound_list[index].PtrToSmth);
|
||||
sound_list[index] = {};
|
||||
sound_count = 1;
|
||||
}
|
||||
|
||||
|
@ -151,11 +151,17 @@ int loader::get_sound_id(int groupIndex)
|
|||
sprintf_s(fileName2, pb::FullTiltMode ? "SOUND\\%s" : "%s", fileName);
|
||||
pinball::make_path_name(filePath, fileName2);
|
||||
|
||||
float duration = -1;
|
||||
HFILE hFile = _lopen(filePath, 0);
|
||||
_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);
|
||||
if (hFile != HFILE_ERROR)
|
||||
{
|
||||
_lread(hFile, &wavHeader, sizeof wavHeader);
|
||||
_lclose(hFile);
|
||||
auto sampleCount = wavHeader.data_size / (wavHeader.channels * (wavHeader.bits_per_sample / 8.0));
|
||||
duration = static_cast<float>(sampleCount / wavHeader.sample_rate);
|
||||
}
|
||||
|
||||
sound_list[soundIndex].Duration = duration;
|
||||
sound_list[soundIndex].WavePtr = Sound::LoadWaveFile(filePath);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue