ge211
2021.5.1
A student game engine
|
|
3 #include "ge211_forward.hxx"
4 #include "ge211_error.hxx"
5 #include "ge211_time.hxx"
6 #include "ge211_util.hxx"
35 bool empty()
const {
return real_empty_(); }
39 explicit operator bool()
const {
return !real_empty_(); }
68 virtual void real_clear_() = 0;
72 virtual bool real_empty_()
const = 0;
110 void real_clear_()
override;
111 bool real_empty_()
const override;
145 void real_clear_()
override;
146 bool real_empty_()
const override;
195 friend class detail::lazy_ptr<
Mixer>;
269 return current_music_;
363 void poll_channels_();
364 friend class detail::Engine;
368 int find_empty_channel_()
const;
375 void unregister_effect_(
int channel);
385 int available_effect_channels_;
407 explicit operator bool()
const;
464 , effect(std::move(e))
466 , state(
Mixer::State::playing)
A music track, which can be attached to the Mixer and played.
Used to control a Sound_effect after it is started playing on a Mixer.
void load(const std::string &, const Mixer &)
Loads audio from a resource file into this audio clip instance.
const Music_track & get_music() const
Gets the Music_track currently attached to this Mixer, if any.
const Sound_effect & get_effect() const
Gets the Sound_effect being played by this handle.
void pause_all_effects()
Pauses all currently-playing effects.
@ playing
Actively playing.
bool empty() const
Recognizes the empty sound effect handle.
Mixer & operator=(const Mixer &)=delete
The mixer cannot be copied.
void pause()
Pauses the effect.
The game engine namespace.
@ fading_out
In the process of fading out from playing to paused (for music) or to halted and detached (for sound ...
bool is_enabled() const
Returns whether the mixer is enabled.
void stop()
Stops the effect from playing and detaches it.
Common interface to classes that load audio data, Music_track and Sound_effect.
void resume_music(Duration fade_in=Duration(0), bool forever=false)
Plays the currently attached music from the current saved position.
Sound_effect()
Default-constructs the empty sound effect track.
void pause_music(Duration fade_out=Duration(0))
Pauses the currently attached music, fading out if requested.
void attach_music(Music_track)
Attaches the given music track to this mixer.
void resume()
Unpauses the effect.
Mixer & operator=(const Mixer &&)=delete
The mixer cannot be moved.
bool empty() const
Returns true if this audio clip is empty.
double get_music_volume() const
Returns the music volume as a number from 0.0 to 1.0.
~Mixer()
Destructor, to clean up the mixer's resources.
A class for timing intervals while supporting pausing.
@ paused
Attached but not playing.
void clear()
Unloads any audio data, leaving this Audio_clip empty.
bool try_load(const std::string &, const Mixer &)
Attempts to load audio from a resource file into this Audio_clip instance.
Mixer::State get_state() const
Gets the state of this effect.
Sound_effect_handle try_play_effect(Sound_effect effect, double volume=1.0)
Attempts to play the given effect track on this mixer, returning an empty Sound_effect_handle if no e...
State
The state of an audio channel.
@ detached
No track is attached to the channel, or no channel is attached to the handle.
void set_volume(double unit_value)
Sets the playing sound effect's volume as a number from 0.0 to 1.0.
Music_track()
Default-constructs the empty music track.
The entity that coordinates playing all audio tracks.
A sound effect track, which can be attached to a Mixer channel and played.
void set_music_volume(double unit_value)
Sets the music volume, on a scale from 0.0 to 1.0.
void resume_all_effects()
Unpauses all currently-paused effects.
State get_music_state() const
Returns the current state of the attached music, if any.
Mixer(const Mixer &&)=delete
The mixer cannot be moved.
Sound_effect_handle play_effect(Sound_effect effect, double volume=1.0)
Plays the given effect track on this mixer, at the specified volume.
void play_music(Music_track, bool forever=false)
Attaches the given music track to this mixer and starts it playing.
void rewind_music()
Rewinds the music to the beginning.
double get_volume() const
Returns the playing sound effect's volume as a number from 0.0 to 1.0.
int available_effect_channels() const
How many effect channels are currently unused? If this is positive, then we can play an additional so...
This is the abstract base class for deriving games.
Mixer(const Mixer &)=delete
The mixer cannot be copied.
Sound_effect_handle()
Default-constructs the empty sound effect handle.