41 void InitializeSoundPool()
52 if (index >= _sounds.
Length())
return NULL;
53 return &_sounds[index];
70 if (sound->file_offset == SIZE_MAX || sound->file_slot == 0)
return false;
85 char *name =
AllocaM(
char, name_len + 1);
89 if (name[name_len] != 0) {
90 DEBUG(grf, 2,
"LoadNewGRFSound [%s]: Name not properly terminated",
FioGetFilename(sound->file_slot));
94 DEBUG(grf, 2,
"LoadNewGRFSound [%s]: Sound name '%s'...",
FioGetFilename(sound->file_slot), name);
97 DEBUG(grf, 1,
"LoadNewGRFSound [%s]: Missing RIFF header",
FioGetFilename(sound->file_slot));
102 uint header_size = 11;
104 if (total_size + name_len + header_size > num) {
105 DEBUG(grf, 1,
"LoadNewGRFSound [%s]: RIFF was truncated",
FioGetFilename(sound->file_slot));
110 DEBUG(grf, 1,
"LoadNewGRFSound [%s]: Invalid RIFF type",
FioGetFilename(sound->file_slot));
114 while (total_size >= 8) {
118 if (total_size < size) {
128 DEBUG(grf, 1,
"LoadGRFSound [%s]: Invalid audio format",
FioGetFilename(sound->file_slot));
142 sound->file_size = size;
145 DEBUG(grf, 2,
"LoadNewGRFSound [%s]: channels %u, sample rate %u, bits per sample %u, length %u",
FioGetFilename(sound->file_slot), sound->channels, sound->rate, sound->bits_per_sample, size);
157 DEBUG(grf, 1,
"LoadNewGRFSound [%s]: RIFF does not contain any sound data",
FioGetFilename(sound->file_slot));
176 if (file == NULL || sound_id >= file->num_sounds)
return INVALID_SOUND;
178 return file->sound_offset + sound_id;
195 if (file == NULL)
return false;
207 if (callback == INVALID_SOUND)
return true;
209 assert(callback < GetNumSounds());
210 SndPlayVehicleFx(callback, v);
223 if (sound_id == INVALID_SOUND)
return;
225 assert(sound_id < GetNumSounds());
226 SndPlayTileFx(sound_id, tile);