nngn
Loading...
Searching...
No Matches
gen.h
Go to the documentation of this file.
1#ifndef NNGN_TOOLS_AUDIO_GEN_H
2#define NNGN_TOOLS_AUDIO_GEN_H
3
4#include <QString>
5
6#include "audio/audio.h"
7#include "lua/state.h"
8#include "utils/flags.h"
9
10namespace nngn {
11
12class Generator {
13public:
14 bool init(std::size_t rate);
15 std::size_t pos(void) const;
16 bool set_loop(bool b);
17 void set_rewind(bool b) { this->flags.set(Flag::REWIND, b); }
18 bool set_mute(bool b);
19 bool set_gain(float g);
20 void set_param(float p) { this->param = p; }
21 auto release_data(void) { return std::move(this->wav_data); }
22 std::string_view error(void) const { return this->m_error; }
23 bool generate(const QString &prog);
24 bool stop(void) { return this->audio.stop(this->source); }
25private:
26 enum Flag : u8 {
27 LOOP = 1 << 0,
28 REWIND = 1 << 1,
29 MUTE = 1 << 2,
30 };
31 bool has_source(void) const { return static_cast<bool>(this->source); }
33 bool play(void);
35 nngn::Math math = {};
36 nngn::Audio audio = {};
38 float gain = 1, param = 0;
39 std::vector<std::byte> wav_data = {};
40 std::string m_error = {};
42};
43
44}
45
46#endif
Audio manager.
Definition: audio.h:17
bool stop(source s) const
Definition: openal.cpp:34
source
Definition: audio.h:19
void set_param(float p)
Definition: gen.h:20
float param
Definition: gen.h:38
std::vector< std::byte > wav_data
Definition: gen.h:39
Flag
Definition: gen.h:26
@ REWIND
Definition: gen.h:28
@ MUTE
Definition: gen.h:29
@ LOOP
Definition: gen.h:27
nngn::lua::value push_msgh(void)
std::string m_error
Definition: gen.h:40
auto release_data(void)
Definition: gen.h:21
nngn::Audio audio
Definition: gen.h:36
bool play(void)
bool set_loop(bool b)
void set_rewind(bool b)
Definition: gen.h:17
bool stop(void)
Definition: gen.h:24
bool init(std::size_t rate)
bool has_source(void) const
Definition: gen.h:31
nngn::Flags< Flag > flags
Definition: gen.h:41
bool generate(const QString &prog)
std::string_view error(void) const
Definition: gen.h:22
nngn::Math math
Definition: gen.h:35
bool set_mute(bool b)
nngn::Audio::source source
Definition: gen.h:37
std::size_t pos(void) const
bool set_gain(float g)
nngn::lua::state lua
Definition: gen.h:34
float gain
Definition: gen.h:38
Definition: math.h:22
g
Definition: gamma.lua:7
p
Definition: input.lua:29
rate
Definition: lemon.lua:2
Definition: audio.cpp:7
std::uint8_t u8
Definition: def.h:12
Wrapper for an unsigned integral representing flags.
Definition: flags.h:18
constexpr Flags & set(AT a)
Definition: flags.h:28
Owning lua_State wrapper.
Definition: state.h:166
Owning stack value reference.
Definition: value.h:48