OpenTTD Source: MusicDriver Class Reference

OpenTTD Source 15.0-beta1

Public Member Functions | Static Public Member Functions
MusicDriver Class Referenceabstract

Driver for all music playback. More...

`#include <music_driver.hpp>`

Inheritance diagram for MusicDriver:

## Public Member Functions
virtual void | PlaySong (const MusicSongInfo &song)=0
| Play a particular song.
virtual void | StopSong ()=0
| Stop playing the current song.
virtual bool | IsSongPlaying ()=0
| Are we currently playing a song?
virtual void | SetVolume (uint8_t vol)=0
| Set the volume, if possible.
Public Member Functions inherited from Driver
virtual std::optional< std::string_view > | Start (const StringList &parm)=0
| Start this driver.
virtual void | Stop ()=0
| Stop this driver.
virtual std::string_view | GetName () const =0
| Get the name of this driver.

## Static Public Member Functions
static MusicDriver * | GetInstance ()
| Get the currently active instance of the music driver.

## Additional Inherited Members
Public Types inherited from Driver
enum | Type { DT_BEGIN = 0 , DT_MUSIC = 0 , DT_SOUND , DT_VIDEO , DT_END }
| The type of driver. More...

## Detailed Description

Driver for all music playback.

Definition at line 18 of file music_driver.hpp.

## Member Function Documentation

## ◆ GetInstance()

static MusicDriver * MusicDriver::GetInstance | ( |  | ) |
| inlinestatic

Get the currently active instance of the music driver.

Definition at line 46 of file music_driver.hpp.

References Driver::DT_MUSIC, and DriverFactoryBase::GetActiveDriver().

Referenced by CrashLog::AfterCrashLogCleanup(), MusicSystem::CheckStatus(), MusicWindow::OnClick(), GameOptionsWindow::OnClick(), AfterNewGRFScan::OnNewGRFsScanned(), MusicSystem::Play(), MusicSystem::Stop(), and SurveyConfiguration().

## ◆ IsSongPlaying()

virtual bool MusicDriver::IsSongPlaying | ( |  | ) |
| pure virtual

Are we currently playing a song?

Returns
  True if a song is being played.

Implemented in MusicDriver_Allegro, MusicDriver_BeMidi, MusicDriver_Cocoa, MusicDriver_DMusic, MusicDriver_ExtMidi, MusicDriver_FluidSynth, MusicDriver_Null, and MusicDriver_Win32.

## ◆ PlaySong()

virtual void MusicDriver::PlaySong | ( | const MusicSongInfo & | song | ) |
| pure virtual

Play a particular song.

Parameters

  song | The information for the song to play.

Implemented in MusicDriver_Null, MusicDriver_Allegro, MusicDriver_BeMidi, MusicDriver_Cocoa, MusicDriver_DMusic, MusicDriver_ExtMidi, MusicDriver_FluidSynth, and MusicDriver_Win32.

Referenced by MusicSystem::Play().

## ◆ SetVolume()

virtual void MusicDriver::SetVolume | ( | uint8_t | vol | ) |
| pure virtual

Set the volume, if possible.

Parameters

  vol | The new volume.

Implemented in MusicDriver_Allegro, MusicDriver_BeMidi, MusicDriver_Cocoa, MusicDriver_DMusic, MusicDriver_ExtMidi, MusicDriver_FluidSynth, MusicDriver_Win32, and MusicDriver_Null.

Referenced by MusicWindow::OnClick(), GameOptionsWindow::OnClick(), and AfterNewGRFScan::OnNewGRFsScanned().

## ◆ StopSong()

virtual void MusicDriver::StopSong | ( |  | ) |
| pure virtual

Stop playing the current song.

Implemented in MusicDriver_Allegro, MusicDriver_BeMidi, MusicDriver_Cocoa, MusicDriver_DMusic, MusicDriver_ExtMidi, MusicDriver_FluidSynth, MusicDriver_Null, and MusicDriver_Win32.

Referenced by MusicSystem::Play(), and MusicSystem::Stop().

The documentation for this class was generated from the following file:

- src/music/music_driver.hpp