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));
179 if (file == NULL)
return false;
192 if (callback > file->num_sounds)
return true;
194 callback += file->sound_offset;
197 assert(callback < GetNumSounds());
198 SndPlayVehicleFx(callback, v);
212 if (sound_id > file->num_sounds)
return;
213 sound_id += file->sound_offset;
216 assert(sound_id < GetNumSounds());
217 SndPlayTileFx(sound_id, tile);