# MusicDriver_QtMidi Class Reference

Inheritance diagram for MusicDriver_QtMidi:

## Public Member Functions

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

## Detailed Description

Definition at line 17 of file qtmidi.h.

## Member Function Documentation

bool MusicDriver_QtMidi::IsSongPlaying | ( |  | ) | `[virtual]`

Checks wether 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.

void MusicDriver_QtMidi::PlaySong | ( | const char * | filename | ) | `[virtual]`

Starts playing a new song.

Parameters:

  | filename | Path to a MIDI file.

Implements MusicDriver.

Definition at line 261 of file qtmidi.cpp.

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

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:

  | vol | The 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, QT_STATE_IDLE, QT_STATE_PLAY, QT_STATE_STOP, and VOLUME.

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().

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, QT_STATE_IDLE, QT_STATE_PLAY, QT_STATE_STOP, and StopSong().

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

- src/music/qtmidi.h
- src/music/qtmidi.cpp