OpenTTD Source 20250331-master-g3c15e0c889
base_media_music.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef BASE_MEDIA_MUSIC_H
11#define BASE_MEDIA_MUSIC_H
12
13#include "base_media_base.h"
14
16static const uint NUM_SONGS_CLASS = 10;
18static const uint NUM_SONG_CLASSES = 3;
21
23static const uint NUM_SONGS_PLAYLIST = 32;
24
25/* Functions to read DOS music CAT files, similar to but not quite the same as sound effect CAT files */
26std::optional<std::string> GetMusicCatEntryName(const std::string &filename, size_t entrynum);
27std::optional<std::vector<uint8_t>> GetMusicCatEntryData(const std::string &filename, size_t entrynum);
28
33
45
46template <> struct BaseSetTraits<struct MusicSet> {
47 static constexpr size_t num_files = NUM_SONGS_AVAILABLE;
48 static constexpr bool search_in_tars = false;
49 static constexpr std::string_view set_type = "music";
50};
51
53struct MusicSet : BaseSet<MusicSet> {
57 uint8_t num_available = 0;
58
59 bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename);
60};
61
63class BaseMusic : public BaseMedia<MusicSet> {
64public:
66 static inline std::string ini_set;
67};
68
69#endif /* BASE_MEDIA_MUSIC_H */
Generic functions for replacing base data (graphics, sounds).
std::optional< std::string > GetMusicCatEntryName(const std::string &filename, size_t entrynum)
Read the name of a music CAT file entry.
Definition music.cpp:25
static const uint NUM_SONG_CLASSES
Number of classes for songs.
static const uint NUM_SONGS_AVAILABLE
Maximum number of songs in the full playlist; theme song + the classes.
static const uint NUM_SONGS_CLASS
Maximum number of songs in the 'class' playlists.
static const uint NUM_SONGS_PLAYLIST
Maximum number of songs in the (custom) playlist.
std::optional< std::vector< uint8_t > > GetMusicCatEntryData(const std::string &filename, size_t entrynum)
Read the full data of a music CAT file entry.
Definition music.cpp:49
MusicTrackType
@ MTT_MPSMIDI
MPS GM driver MIDI format (contained in a CAT file)
@ MTT_STANDARDMIDI
Standard MIDI file.
Base for all base media (graphics, sounds)
All data/functions related with replacing the base music.
static std::string ini_set
The set as saved in the config file.
Defines the traits of a BaseSet type.
Information about a single base set.
Ini file that supports both loading and saving.
Definition ini_type.h:88
All data of a music set.
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE]
Data about individual songs in set.
uint8_t num_available
Number of valid songs in set.
Metadata about a music track.
MusicTrackType filetype
decoder required for song file
std::string songname
name of song displayed in UI
uint8_t tracknr
track number of song displayed in UI
std::string filename
file on disk containing song (when used in MusicSet class)
int override_start
MIDI ticks to skip over in beginning.
bool loop
song should play in a tight loop if possible, never ending
int cat_index
entry index in CAT file, for filetype==MTT_MPSMIDI
int override_end
MIDI tick to end the song at (0 if no override)