JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
sound.hpp
Go to the documentation of this file.
1// Copyright 2012-2024 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include "Finally.hpp"
8
9#include <memory>
10#include <string>
11
12namespace jngl {
13
14class SoundFile;
15
16float getVolume();
17
21void play(const std::string& filename);
22
24void stop(const std::string& filename);
25
33bool isPlaying(const std::string& filename);
34
40
42void setPlaybackSpeed(float speed);
43
45void setVolume(float volume);
46
82[[nodiscard]] Finally pauseAudio();
83
84} // namespace jngl
Contains jngl::Finally class.
Helper class which calls a function when being destroyed.
Definition Finally.hpp:22
JNGL's main namespace.
bool isPlaying(const std::string &filename)
void setVolume(float volume)
Set global volume in [0, ∞]. Default is 1.0f.
void setPlaybackSpeed(float speed)
Set global pitch in (0.0f, ∞]. Default is 1.0f.
void play(const std::string &filename)
Play an OGG audio file once.
std::shared_ptr< SoundFile > loop(const std::string &filename)
Play an OGG audio file in a loop.
void stop(const std::string &filename)
Stop an OGG audio file if it's currently playing.
Finally pauseAudio()
Pauses the playback of all audio; destroying the returned Finally object will resume again.