OpenTTD
Public Member Functions
MusicDriver_QtMidi Class Reference
Inheritance diagram for MusicDriver_QtMidi:
MusicDriver Driver

Public Member Functions

const char * Start (const char *const *param)
 Initialized the MIDI player, including QuickTime initialization. More...
 
void Stop ()
 Stops the MIDI player. More...
 
void PlaySong (const char *filename)
 Starts playing a new song. More...
 
void StopSong ()
 Stops playing the current song, if the player is active.
 
bool IsSongPlaying ()
 Checks whether the player is active. More...
 
void SetVolume (byte vol)
 Changes the playing volume of the MIDI player. More...
 
const char * GetName () const
 Get the name of this driver. More...
 

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...
 
- Static Public Member Functions inherited from MusicDriver
static MusicDriverGetInstance ()
 Get the currently active instance of the music driver.
 

Detailed Description

Definition at line 17 of file qtmidi.h.

Member Function Documentation

◆ GetName()

const char* MusicDriver_QtMidi::GetName ( ) const
inlinevirtual

Get the name of this driver.

Returns
The name of the driver.

Implements Driver.

Definition at line 30 of file qtmidi.h.

◆ IsSongPlaying()

bool MusicDriver_QtMidi::IsSongPlaying ( )
virtual

Checks whether the player is active.

This function is called at regular intervals from OpenTTD's main loop, so we call MoviesTask() from here to let QuickTime do its work.

Implements MusicDriver.

Definition at line 202 of file qtmidi.cpp.

References _quicktime_movie, _quicktime_started, _quicktime_state, QT_STATE_IDLE, QT_STATE_PLAY, and QT_STATE_STOP.

◆ PlaySong()

void MusicDriver_QtMidi::PlaySong ( const char *  filename)
virtual

Starts playing a new song.

Parameters
filenamePath to a MIDI file.

Implements MusicDriver.

Definition at line 261 of file qtmidi.cpp.

References _quicktime_movie, _quicktime_started, _quicktime_state, DEBUG, LoadMovieForMIDIFile(), QT_STATE_IDLE, QT_STATE_PLAY, QT_STATE_STOP, StopSong(), and VOLUME.

◆ SetVolume()

void MusicDriver_QtMidi::SetVolume ( byte  vol)
virtual

Changes the playing volume of the MIDI player.

As QuickTime controls volume in a per-movie basis, the desired volume is stored in _quicktime_volume, and the volume is set here using the VOLUME macro, and when loading new song in PlaySong.

Parameters
volThe desired volume, range of the value is 0-127

Implements MusicDriver.

Definition at line 321 of file qtmidi.cpp.

References _quicktime_movie, _quicktime_started, _quicktime_state, _quicktime_volume, DEBUG, QT_STATE_IDLE, QT_STATE_PLAY, QT_STATE_STOP, and VOLUME.

◆ Start()

const char * MusicDriver_QtMidi::Start ( const char *const *  parm)
virtual

Initialized the MIDI player, including QuickTime initialization.

Todo:
Give better error messages by inspecting error codes returned by Gestalt() and EnterMovies(). Needs changes in InitQuickTimeIfNeeded.

Implements Driver.

Definition at line 189 of file qtmidi.cpp.

References _quicktime_started, and InitQuickTimeIfNeeded().

◆ Stop()

void MusicDriver_QtMidi::Stop ( )
virtual

Stops the MIDI player.

Stops playing and frees any used resources before returning. As it deinitilizes QuickTime, the _quicktime_started flag is set to false.

Implements Driver.

Definition at line 232 of file qtmidi.cpp.

References _quicktime_movie, _quicktime_started, _quicktime_state, DEBUG, QT_STATE_IDLE, QT_STATE_PLAY, QT_STATE_STOP, and StopSong().


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