15#if defined(__has_include) && __has_include(<optional>)
19#include <experimental/optional>
126 std::weak_ptr<Sound> sound;
127 std::shared_ptr<
std::vector<
float>> buffer;
Contains jngl::SoundPanning class.
An audio channel, different channels could be for example: "Music", "Speech" and "Sound Effects".
Sound loaded from an OGG or MP3 file.
SoundPanning playWithPanning()
Like play(), but the sound can be positioned in the stereo field.
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 or MP3 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.
SoundPanning loopWithPanning()
Like loop(), but the sound can be positioned in the stereo field.
void loop()
Play the sound in a loop. Can also be stopped using stop()
A sound which can be positioned in the stereo field.