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 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 SoundFile;
14struct Stream;
15
29class Channel {
30public:
31 Channel();
32 ~Channel();
33
35 void play(const std::string& filename);
36
41
43 void stop(const std::string& filename);
44
80 [[nodiscard]] Finally pause();
81
83 void setVolume(float volume);
84
86 static Channel& main();
87
91 void remove(const Stream*);
92
93private:
94 struct Impl;
96};
97
98} // namespace jngl
Contains jngl::Finally class.
An audio channel, different channels could be for example: "Music", "Speech" and "Sound Effects".
Definition Channel.hpp:29
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 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.