JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Channel.hpp
Go to the documentation of this file.
1// Copyright 2024-2025 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5
6#include "Finally.hpp"
7
8#include <memory>
9#include <string>
10
11namespace jngl {
12
13class Sound;
14class SoundFile;
15struct Stream;
16
30class Channel {
31public:
32 Channel();
33 ~Channel();
34
36 void play(const std::string& filename);
37
40
45
47 void stop(const std::string& filename);
48
51
55 void stopAll();
56
92 [[nodiscard]] Finally pause();
93
95 void setVolume(float volume);
96
98 static Channel& main();
99
103 void remove(const Stream*);
104
105private:
106 struct Impl;
108};
109
110} // namespace jngl
Contains jngl::Finally class.
An audio channel, different channels could be for example: "Music", "Speech" and "Sound Effects".
Definition Channel.hpp:30
Finally pause()
Pauses the Channel; destroying the returned Finally object will resume again.
static Channel & main()
Returns the main Channel on which jngl::play, jngl::loop, jngl::stop operate.
void setVolume(float volume)
Set volume of this channel in [0, ∞]. Default is 1.0f.
void remove(const Stream *)
Internal function for now.
void stopAll()
Stops all audio playing on this channel.
void play(std::shared_ptr< Sound >)
Play a Sound on this channel.
void stop(const std::shared_ptr< Sound > &)
Stop a Sound if it's playing on this channel.
void add(std::shared_ptr< Stream >)
Internal function for now.
void play(const std::string &filename)
Play OGG file on this channel.
std::shared_ptr< SoundFile > loop(const std::string &filename)
Play an OGG audio file on this channel in a loop.
void stop(const std::string &filename)
Stop OGG file playing on this channel.
Helper class which calls a function when being destroyed.
Definition Finally.hpp:22
JNGL's main namespace.