ge211  2021.5.1
A student game engine
Music_track Class Reference

Detailed Description

A music track, which can be attached to the Mixer and played.

A music track may be empty or non-empty; only non-empty tracks can actually be played.

Note that Music_track has few public member functions. However, a music track can be passed to these Mixer member functions to play it:

Note also that the mixer can only play one music track at a time.

Definition at line 86 of file ge211_audio.hxx.

+ Inheritance diagram for Music_track:
+ Collaboration diagram for Music_track:

Public Member Functions

 Music_track (const std::string &filename, const Mixer &)
 Loads a new music track from a resource file. More...
 
 Music_track ()
 Default-constructs the empty music track.
 
- Public Member Functions inherited from Audio_clip
bool empty () const
 Returns true if this audio clip is empty.
 
 operator bool () const
 Recognizes a non-empty audio clip. More...
 
void load (const std::string &, const Mixer &)
 Loads audio from a resource file into this audio clip instance. More...
 
bool try_load (const std::string &, const Mixer &)
 Attempts to load audio from a resource file into this Audio_clip instance. More...
 
void clear ()
 Unloads any audio data, leaving this Audio_clip empty.
 

Constructor & Destructor Documentation

◆ Music_track()

Music_track ( const std::string filename,
const Mixer mixer 
)

Loads a new music track from a resource file.

Supported file formats may include WAV, MP3, OGG, FLAC, MID, and ABC. Which you actually get depends on which options were enabled when your copy of the SDL2_mixer library that ge211 links against was compiled.

Pausing and resuming does not work correctly with all audio formats.

Throws exceptions::File_error if the file cannot be opened, and exceptions::Mixer_error if the file format cannot be understood.

Definition at line 48 of file ge211_audio.cxx.


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