5#include <aegis2d/audio/export.hpp>
22class AEGIS2D_AUDIO_EXPORT
AudioError :
public std::runtime_error {
24 using std::runtime_error::runtime_error;
57 static constexpr std::size_t max_voices = 32;
83 [[nodiscard]] std::size_t
sounds() const noexcept;
116 void play_music(
SoundId sound,
bool loop = true);
119 void stop_music() noexcept;
123 [[nodiscard]]
bool music_playing() const noexcept;
130 void stop_all() noexcept;
136 void set_volumes(const
Volumes& volumes) noexcept;
140 [[nodiscard]]
Volumes volumes() const noexcept;
143 void update() noexcept;
147 [[nodiscard]]
std::
size_t playing() const noexcept;
152 [[nodiscard]]
std::
size_t playing(
Channel channel) const noexcept;
156 std::unique_ptr<Impl> impl_;
176[[nodiscard]] inline
std::pair<
float,
float> positional(
Vec2 position,
Vec2 camera_center,
177 float view_half_width) noexcept {
178 const Vec2 offset = position - camera_center;
179 const float pan = std::clamp(offset.x / view_half_width, -1.0F, 1.0F);
181 std::clamp(1.0F - std::hypot(offset.x, offset.y) / view_half_width, 0.0F, 1.0F);
The default audio output and the sounds it plays.
Definition audio.hpp:54
AudioDevice & operator=(AudioDevice &&other) noexcept
Closes this device and takes over the device of other.
std::size_t sounds() const noexcept
Number of sounds loaded.
AudioDevice()
Opens the default audio output of the system.
AudioDevice & operator=(const AudioDevice &)=delete
AudioDevice(const AudioDevice &)=delete
~AudioDevice()
Stops every sound and closes the device.
AudioDevice(AudioDevice &&other) noexcept
Takes over the device of other, which must not be used afterwards.
SoundId load(const std::filesystem::path &path)
Loads a sound from a WAV file.
Thrown when the audio device cannot be opened or a sound cannot be loaded.
Definition audio.hpp:22
Vector and matrix types of the engine (GLM behind engine names).
Sound effects and music on top of SDL3 (client only).
Definition audio.hpp:17
Channel
Group of sounds whose volume is set together.
Definition audio.hpp:28
@ Effects
Short sounds of the game: shots, explosions, menus.
std::size_t SoundId
Identifier of a sound loaded by an AudioDevice, given by AudioDevice::load().
Definition audio.hpp:36
glm::vec2 Vec2
2D vector of floats: positions, velocities, sizes (glm::vec2).
Definition math.hpp:19
Definition endpoint.hpp:85
Positions of the three volume sliders of a settings menu, from 0 (silent) to 1.
Definition volume.hpp:18