4 #include <SDL2/SDL_mixer.h> 35 SoundEffect(std::string path,
Object *parent =
nullptr, std::string name =
"SoundEffect");
59 void Play(
int channel = -1);
92 Music(
Object *parent =
nullptr, std::string name =
"Music");
99 Music(std::string path,
Object *parent =
nullptr, std::string name =
"Music");
107 void SetPath(std::string path);
123 void Play(
bool loop =
false,
double fadeIn = 0.0);
126 void Stop(
double fadeOut = 0.0);
148 Audio(
Object *parent =
nullptr, std::string name =
"Audio");
void SetPath(std::string path)
Sets the file path and loads the new file.
bool Load()
Loads the music from the current path.
void Stop()
Stops any instance of the sound currently playing.
void Play(bool loop=false, double fadeIn=0.0)
Plays this music.
Object(Object *parent=nullptr, std::string name="Object")
Constructor Derived classes should call this in their constructors' initialization list.
Mix_Music * _music
loaded music file
Definition: Audio.hpp:85
void Stop(double fadeOut=0.0)
Stops this music if is currently playing.
Audio class.
Definition: Audio.hpp:137
General base class Allows for parent/child relationship trees.
Definition: Object.hpp:33
bool IsPlaying()
Determines if this music is currently playing.
SoundEffect(Object *parent=nullptr, std::string name="SoundEffect")
Constructor.
std::vector< unsigned > _channels
Channels the sound has been played on.
Definition: Audio.hpp:21
SoundEffect class.
Definition: Audio.hpp:14
bool Load()
Loads the current file path.
static Music * _lastPlayed
Tracks the last music file that was played.
Definition: Audio.hpp:81
std::string GetPath()
Gets the file path.
bool IsPlayingOn(int channel)
Determines if the sound is playing on a given channel.
void End()
Shuts down and invalidates Object and all of its children An invalid child Object will be deleted by ...
Mix_Music * GetMusic()
Gets the unwrapped SDL_Mixer music.
Audio(Object *parent=nullptr, std::string name="Audio")
Constructor Derived classes should call this in their constructors' initialization list.
Mix_Chunk * _sound
Loaded sound chunk.
Definition: Audio.hpp:19
bool IsPlayingMusic()
Determines if any music is currently playing.
void End()
Shuts down and invalidates Object and all of its children An invalid child Object will be deleted by ...
void End()
Shuts down and invalidates Object and all of its children An invalid child Object will be deleted by ...
void Play(int channel=-1)
Plays the sound on a given channel.
bool IsPlaying()
Determines if the sound is playing on any channel.
void SetPath(std::string path)
Sets the file path and loads the new file.
Music(Object *parent=nullptr, std::string name="Music")
Constructor.
static unsigned _acount
Total number of Audio classes in existence.
Definition: Audio.hpp:140
std::string _path
Path of this music file.
Definition: Audio.hpp:83
Mix_Chunk * GetSound()
Gets the unwrapped SDL_Mixer sound chunk.
void OnDeactivate()
Stops the music from playing if it's currently playing.
Aspen engine namespace.
Definition: Audio.hpp:8
void StopMusic(double fadeOut=0.0)
Stops any music currently playing.
std::string _path
Path to the soundeffect file.
Definition: Audio.hpp:17
std::string GetPath()
Gets the file path.
Music class.
Definition: Audio.hpp:78
void OnDeactivate()
Stops any instance of the sound on deactivation This should be called or reimplemented by derived cla...