OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Enumerations | Functions
newgrf_sound.h File Reference

Functions related to NewGRF provided sounds. More...

`#include "sound_type.h"`
`#include "tile_type.h"`
`#include "vehicle_type.h"`

Go to the source code of this file.

## Enumerations
enum | VehicleSoundEvent { VSE_START = 1, VSE_TUNNEL = 2, VSE_BREAKDOWN = 3, VSE_RUNNING = 4, VSE_TOUCHDOWN = 5, VSE_VISUAL_EFFECT = 6, VSE_RUNNING_16 = 7, VSE_STOPPED_16 = 8, VSE_LOAD_UNLOAD = 9 }
| Events at which a sound might be played. More...

## Functions
SoundEntry * | AllocateSound (uint num)
| Allocate sound slots.
void | InitializeSoundPool ()
bool | LoadNewGRFSound (SoundEntry *sound)
| Extract meta data from a NewGRF sound.
SoundEntry * | GetSound (SoundID sound_id)
uint | GetNumSounds ()
bool | PlayVehicleSound (const Vehicle *v, VehicleSoundEvent event)
| Checks whether a NewGRF wants to play a different vehicle sound effect.
void | PlayTileSound (const struct GRFFile *file, SoundID sound_id, TileIndex tile)

## Detailed Description

Functions related to NewGRF provided sounds.

Definition in file newgrf_sound.h.

## Enumeration Type Documentation

enum VehicleSoundEvent

Events at which a sound might be played.

Enumerator:

  VSE_START | Vehicle starting, i.e. leaving, the station.
  VSE_TUNNEL | Train entering a tunnel.
  VSE_BREAKDOWN | Vehicle breaking down.
  VSE_RUNNING | Vehicle running normally.
  VSE_TOUCHDOWN | Whenever a plane touches down.
  VSE_VISUAL_EFFECT | Vehicle visual effect (steam, diesel smoke or electric spark) is shown.
  VSE_RUNNING_16 | Every 16 ticks while the vehicle is running (speed > 0).
  VSE_STOPPED_16 | Every 16 ticks while the vehicle is stopped (speed == 0).
  VSE_LOAD_UNLOAD | Whenever cargo payment is made for a vehicle.

Definition at line 20 of file newgrf_sound.h.

## Function Documentation

SoundEntry* AllocateSound | ( | uint | num | ) |

Allocate sound slots.

Parameters

  num | Number of slots to allocate.

Returns
  First allocated slot.

Definition at line 33 of file newgrf_sound.cpp.

References SmallVector< T, S >::Append(), and MemSetT().

bool LoadNewGRFSound | ( | SoundEntry * | sound | ) |

Extract meta data from a NewGRF sound.

Parameters

  sound | Sound to load.

Returns
  True if a valid sound was loaded.

Definition at line 68 of file newgrf_sound.cpp.

References AllocaM, BSWAP32(), DEBUG, FioGetFilename(), FioGetPos(), FioReadBlock(), FioReadByte(), FioReadDword(), FioReadWord(), FioSeekToFile(), FioSkipBytes(), SoundEntry::grf_container_ver, and MemSetT().

bool PlayVehicleSound | ( | const Vehicle * | v,
|  | VehicleSoundEvent | event
| ) |  |

Checks whether a NewGRF wants to play a different vehicle sound effect.

Parameters

  v | Vehicle to play sound effect for.
  event | Trigger for the sound effect.

Returns
  false if the default sound effect shall be played instead.

Definition at line 171 of file newgrf_sound.cpp.

References _settings_client, CALLBACK_FAILED, CBID_VEHICLE_SOUND_EFFECT, CBM_VEHICLE_SOUND_EFFECT, Vehicle::engine_type, Vehicle::GetGRF(), GetVehicleCallback(), HasBit(), ORIGINAL_SAMPLE_COUNT, ClientSettings::sound, and SoundSettings::vehicle.

Referenced by AircraftController(), AircraftLandAirplane(), Vehicle::HandleBreakdown(), Train::PlayLeaveStationSound(), and Vehicle::ShowVisualEffect().