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