![]() |
Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
|
#include <audio.hpp>
Public Member Functions | |
| AudioSource (const std::string &path) | |
| float | getVolume () const |
| float | getPitch () const |
| bool | getPlaying () const |
| void | setPitch (float pitch) |
| void | setVolume (float volume) |
| void | play () |
| void | stop () |
| void | pause () |
| bool | loadAudio () |
| void | update (float deltaTime) |
| void | exit () |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Member Functions inherited from Component | |
| virtual | ~Component ()=default |
| virtual void | render (std::shared_ptr< Window > window) |
| virtual void | initialize () |
| virtual void | physicsUpdate () |
| virtual void | input (InputEvent &event) |
| virtual void | postLoad () |
| Node * | getNode () const |
| void | setNode (Node *n) |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Attributes | |
| std::string | path |
| bool | loop = false |
| Signal | finished |
| Signal | looped |
| Signal | stopped |
| Signal | paused |
The source of a one-dimensional sound. For now, you can only load WAV files because of SDL audio streams. You can modify its pitch and volume and loop it. It also has a Signal for when the sound finishes playing.
Example Usage:
You can set and get its pitch:
You can also modify its volume:
It also has a loop attribute:
You can also register callbacks to all of the events it has for when the sound is finished, looped, stopped and paused.
Make sure to also check out the audio example for more information!
| AudioSource::AudioSource | ( | const std::string & | path | ) |
|
virtual |
Reimplemented from Component.
| float AudioSource::getPitch | ( | ) | const |
| bool AudioSource::getPlaying | ( | ) | const |
| float AudioSource::getVolume | ( | ) | const |
|
inline |
| bool AudioSource::loadAudio | ( | ) |
| void AudioSource::pause | ( | ) |
| void AudioSource::play | ( | ) |
|
inline |
| void AudioSource::setPitch | ( | float | pitch | ) |
| void AudioSource::setVolume | ( | float | volume | ) |
| void AudioSource::stop | ( | ) |
|
virtual |
Reimplemented from Component.
| Signal AudioSource::finished |
| bool AudioSource::loop = false |
| Signal AudioSource::looped |
| std::string AudioSource::path |
| Signal AudioSource::paused |
| Signal AudioSource::stopped |