OpenTTD Source: src/base_media_music.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Enumerations | Functions | Variables
base_media_music.h File Reference

Generic functions for replacing base music data. More...

`#include "base_media_base.h"`

Go to the source code of this file.

## Data Structures
struct | MusicSongInfo
| Metadata about a music track. More...
struct | BaseSetTraits< struct MusicSet >
struct | MusicSet
| All data of a music set. More...
class | BaseMusic
| All data/functions related with replacing the base music. More...

## Enumerations
enum | MusicTrackType : uint8_t { MTT_STANDARDMIDI , MTT_MPSMIDI }

## Functions
std::optional< std::string > | GetMusicCatEntryName (const std::string &filename, size_t entrynum)
| Read the name of a music CAT file entry.
std::optional< std::vector< uint8_t > > | GetMusicCatEntryData (const std::string &filename, size_t entrynum)
| Read the full data of a music CAT file entry.

## Variables
static const uint | NUM_SONGS_CLASS = 10
| Maximum number of songs in the 'class' playlists.
static const uint | NUM_SONG_CLASSES = 3
| Number of classes for songs.
static const uint | NUM_SONGS_AVAILABLE = 1 + NUM_SONG_CLASSES * NUM_SONGS_CLASS
| Maximum number of songs in the full playlist; theme song + the classes.
static const uint | NUM_SONGS_PLAYLIST = 32
| Maximum number of songs in the (custom) playlist.

## Detailed Description

Generic functions for replacing base music data.

Definition in file base_media_music.h.

## Enumeration Type Documentation

## ◆ MusicTrackType

enum MusicTrackType : uint8_t

Enumerator
MTT_STANDARDMIDI | Standard MIDI file.
MTT_MPSMIDI | MPS GM driver MIDI format (contained in a CAT file)

Definition at line 29 of file base_media_music.h.

## Function Documentation

## ◆ GetMusicCatEntryData()

std::optional< std::vector< uint8_t > > GetMusicCatEntryData | ( | const std::string & | filename,
|  | size_t | entrynum
| ) |  |

Read the full data of a music CAT file entry.

Parameters

  filename | Name of CAT file to read from.
  entrynum | Index of entry to read

Returns
  Data of CAT file entry.

Definition at line 50 of file music.cpp.

References BASESET_DIR, FioCheckFileExists(), RandomAccessFile::ReadBlock(), RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), RandomAccessFile::SeekTo(), and RandomAccessFile::SkipBytes().

Referenced by MidiFile::GetSMFFile().

## ◆ GetMusicCatEntryName()

std::optional< std::string > GetMusicCatEntryName | ( | const std::string & | filename,
|  | size_t | entrynum
| ) |  |

Read the name of a music CAT file entry.

Parameters

  filename | Name of CAT file to read from
  entrynum | Index of entry whose name to read

Returns
  Name of CAT file entry if it could be read.

Definition at line 26 of file music.cpp.

References BASESET_DIR, FioCheckFileExists(), RandomAccessFile::ReadBlock(), RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), RandomAccessFile::SeekTo(), and StrMakeValid().

## Variable Documentation

## ◆ NUM_SONG_CLASSES

const uint NUM_SONG_CLASSES = 3
| static

Number of classes for songs.

Definition at line 18 of file base_media_music.h.

## ◆ NUM_SONGS_AVAILABLE

const uint NUM_SONGS_AVAILABLE = 1 + NUM_SONG_CLASSES * NUM_SONGS_CLASS
| static

Maximum number of songs in the full playlist; theme song + the classes.

Definition at line 20 of file base_media_music.h.

Referenced by MusicSystem::BuildPlaylists(), and MusicTrackSelectionWindow::UpdateWidgetSize().

## ◆ NUM_SONGS_CLASS

const uint NUM_SONGS_CLASS = 10
| static

Maximum number of songs in the 'class' playlists.

Definition at line 16 of file base_media_music.h.

Referenced by MusicSystem::BuildPlaylists().

## ◆ NUM_SONGS_PLAYLIST

const uint NUM_SONGS_PLAYLIST = 32
| static

Maximum number of songs in the (custom) playlist.

Definition at line 23 of file base_media_music.h.

Referenced by MusicSystem::BuildPlaylists(), MusicSystem::PlaylistAdd(), MusicSystem::SaveCustomPlaylist(), and MusicTrackSelectionWindow::UpdateWidgetSize().