OpenTTD Source: src/mixer.h File Reference

OpenTTD Source 14.0-beta3

Typedefs | Functions
mixer.h File Reference

Go to the source code of this file.

## Typedefs
typedef void(* | MxStreamCallback) (int16_t *buffer, size_t samples)
| Type of callback functions for supplying PCM music. More...

## Functions
bool | MxInitialize (uint rate)
void | MxMixSamples (void *buffer, uint samples)
MixerChannel * | MxAllocateChannel ()
void | MxSetChannelRawSrc (MixerChannel *mc, int8_t *mem, size_t size, uint rate, bool is16bit)
void | MxSetChannelVolume (MixerChannel *mc, uint volume, float pan)
| Set volume and pan parameters for a sound. More...
void | MxActivateChannel (MixerChannel *)
uint32_t | MxSetMusicSource (MxStreamCallback music_callback)
| Set source of PCM music. More...
void | SetEffectVolume (uint8_t volume)

## Detailed Description

Functions to mix sound samples.

Definition in file mixer.h.

## Typedef Documentation

## ◆ MxStreamCallback

typedef void(* MxStreamCallback) (int16_t *buffer, size_t samples)

Type of callback functions for supplying PCM music.

A music decoder/renderer implements this function and installs it with MxSetMusicSource, which also returns the sample rate used.

Parameters

  buffer | Pointer to interleaved 2-channel signed 16 bit PCM data buffer, guaranteed to be 0-initialized.
  samples | number of samples that must be filled into `buffer`.

Definition at line 21 of file mixer.h.

## Function Documentation

## ◆ MxSetChannelVolume()

void MxSetChannelVolume | ( | MixerChannel * | mc,
|  | uint | volume,
|  | float | pan
| ) |  |

Set volume and pan parameters for a sound.

Parameters

  mc | MixerChannel to set
  volume | Volume level for sound, range is 0..16384
  pan | Pan position for sound, range is 0..1

Definition at line 191 of file mixer.cpp.

## ◆ MxSetMusicSource()

uint32_t MxSetMusicSource | ( | MxStreamCallback | music_callback | ) |

Set source of PCM music.

Parameters

  music_callback | Function that will be called to fill sample buffers with music data.

Returns
  Sample rate of mixer, which the buffers supplied to the callback must be rendered at.

Definition at line 211 of file mixer.cpp.

References lock.

Referenced by MusicDriver_FluidSynth::Start(), and MusicDriver_FluidSynth::Stop().