13#if defined(__has_include) && __has_include(<optional>)
17#include <experimental/optional>
106 std::weak_ptr<Sound> sound;
107 std::shared_ptr<
std::vector<
float>> buffer;
An audio channel, different channels could be for example: "Music", "Speech" and "Sound Effects".
Sound loaded from an OGG file.
void play()
Play the sound once. If called twice the sound would also play twice.
SoundFile(const std::string &filename, std::launch policy=std::launch::async)
Load an OGG file called filename.
void load()
Block until the sound file has been fully decompressed and loaded.
std::span< float > getSamples()
Returns the raw audio samples of this SoundFile.
bool isPlaying()
Whether the sound is still playing at least once.
void stop()
Stop the last started sound.
static std::shared_ptr< SoundFile > get(std::string_view filename)
Returns a shared pointer to a SoundFile from JNGL's internal cache, creates it with async loading if ...
std::chrono::milliseconds length() const
Returns the duration in ms.
void setVolume(float v)
Set volume in [0, ∞]. Default is 1.0f.
float progress() const
Returns playing progress in [0, 1], can be used with length() to determine how much time has passed.
void loop()
Play the sound in a loop. Can also be stopped using stop()