mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-02 00:42:53 +01:00
parent
8017734de4
commit
5e42f37fba
@ -447,6 +447,8 @@ int TPinballTable::Message(int code, float value)
|
|||||||
pinball::MissTextBox->Clear();
|
pinball::MissTextBox->Clear();
|
||||||
LightGroup->Message(28, 0.2f);
|
LightGroup->Message(28, 0.2f);
|
||||||
auto time = loader::play_sound(SoundIndex1, nullptr, "TPinballTable2");
|
auto time = loader::play_sound(SoundIndex1, nullptr, "TPinballTable2");
|
||||||
|
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(DatFile* datFile)
|
|||||||
{
|
{
|
||||||
if (sound_count < 65)
|
if (sound_count < 65)
|
||||||
{
|
{
|
||||||
sound_list[sound_count].WavePtr = nullptr;
|
sound_list[sound_count] = {nullptr, groupIndex, 0, 0};
|
||||||
sound_list[sound_count].GroupIndex = groupIndex;
|
|
||||||
sound_count++;
|
sound_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,8 +107,7 @@ void loader::unload()
|
|||||||
for (int index = 1; index < sound_count; ++index)
|
for (int index = 1; index < sound_count; ++index)
|
||||||
{
|
{
|
||||||
Sound::FreeSound(sound_list[index].WavePtr);
|
Sound::FreeSound(sound_list[index].WavePtr);
|
||||||
sound_list[index].Loaded = 0;
|
sound_list[index] = {};
|
||||||
sound_list[index].WavePtr = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sound_count = 1;
|
sound_count = 1;
|
||||||
@ -158,16 +156,18 @@ int loader::get_sound_id(int groupIndex)
|
|||||||
fileName.insert(0, "SOUND");
|
fileName.insert(0, "SOUND");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float duration = -1;
|
||||||
auto filePath = pinball::make_path_name(fileName);
|
auto filePath = pinball::make_path_name(fileName);
|
||||||
auto file = fopenu(filePath.c_str(), "rb");
|
auto file = fopenu(filePath.c_str(), "rb");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
fread(&wavHeader, 1, sizeof wavHeader, file);
|
fread(&wavHeader, 1, sizeof wavHeader, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
auto sampleCount = wavHeader.data_size / (wavHeader.channels * (wavHeader.bits_per_sample / 8.0));
|
||||||
|
duration = static_cast<float>(sampleCount / wavHeader.sample_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sampleCount = wavHeader.data_size / (wavHeader.channels * (wavHeader.bits_per_sample / 8.0));
|
sound_list[soundIndex].Duration = duration;
|
||||||
sound_list[soundIndex].Duration = static_cast<float>(sampleCount / wavHeader.sample_rate);
|
|
||||||
sound_list[soundIndex].WavePtr = Sound::LoadWaveFile(filePath);
|
sound_list[soundIndex].WavePtr = Sound::LoadWaveFile(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user