OpenTTD Source: src/sound.cpp File Reference

OpenTTD Source 12.2

Macros | Functions | Variables
sound.cpp File Reference
`#include "stdafx.h"`
`#include "landscape.h"`
`#include "mixer.h"`
`#include "newgrf_sound.h"`
`#include "random_access_file_type.h"`
`#include "window_gui.h"`
`#include "vehicle_base.h"`
`#include "base_media_func.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Macros
#define | SET_TYPE "sounds"

## Functions
static void | OpenBankFile (const char *filename)
static bool | SetBankSource (MixerChannel *mc, const SoundEntry *sound)
void | InitializeSound ()
static void | StartSound (SoundID sound_id, float pan, uint volume)
void | SndCopyToPool ()
static void | SndPlayScreenCoordFx (SoundID sound, int left, int right, int top, int bottom)
| Decide 'where' (between left and right speaker) to play the sound effect. More...
void | SndPlayTileFx (SoundID sound, TileIndex tile)
void | SndPlayVehicleFx (SoundID sound, const Vehicle *v)
void | SndPlayFx (SoundID sound)

## Variables
static SoundEntry | _original_sounds [ORIGINAL_SAMPLE_COUNT]
static const byte | _vol_factor_by_zoom [] = {255, 255, 255, 190, 134, 87}
static const byte | _sound_base_vol []
static const byte | _sound_idx []
static const char *const | _sound_file_names [] = { "samples" }
| Names corresponding to the sound set's files.

## Detailed Description

Handling of playing sounds.

Definition in file sound.cpp.

## Function Documentation

## ◆ OpenBankFile()

static void OpenBankFile | ( | const char * | filename | ) |
| static

The sound file for the original sounds, i.e. those not defined/overridden by a NewGRF. Needs to be kept alive during the game as _original_sounds[n].file refers to this.

Definition at line 26 of file sound.cpp.

## ◆ SndPlayScreenCoordFx()

static void SndPlayScreenCoordFx | ( | SoundID | sound,
|  | int | left,
|  | int | right,
|  | int | top,
|  | int | bottom
| ) |  |
| static

Decide 'where' (between left and right speaker) to play the sound effect.

Parameters

  sound | Sound effect to play
  left | Left edge of virtual coordinates where the sound is produced
  right | Right edge of virtual coordinates where the sound is produced
  top | Top edge of virtual coordinates where the sound is produced
  bottom | Bottom edge of virtual coordinates where the sound is produced

Definition at line 244 of file sound.cpp.

References _settings_client, MusicSettings::effect_vol, ClientSettings::music, Viewport::virtual_height, Viewport::virtual_left, Viewport::virtual_top, and Viewport::virtual_width.

## Variable Documentation

## ◆ _sound_base_vol

const byte _sound_base_vol[]
| static

Initial value:
= {
128, 90, 128, 128, 128, 128, 128, 128,
128, 90, 90, 128, 128, 128, 128, 128,
128, 128, 128, 80, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 90, 90, 90, 128, 90, 128,
128, 90, 128, 128, 128, 90, 128, 128,
128, 128, 128, 128, 90, 128, 128, 128,
128, 90, 128, 128, 128, 128, 128, 128,
128, 128, 90, 90, 90, 128, 128, 128,
90,
}

Definition at line 200 of file sound.cpp.

## ◆ _sound_idx

const byte _sound_idx[]
| static

Initial value:
= {
2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 0,
1, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71,
72,
}

Definition at line 213 of file sound.cpp.