ReXGlue SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
audio_system.h
Go to the documentation of this file.
1
10
11
#pragma once
12
13
#include <span>
14
#include <string>
15
16
#include <
rex/apu/audio_driver.h
>
17
#include <
rex/platform.h
>
18
#include <
rex/module.h
>
19
#include <
rex/result.h
>
20
#include <
rex/setting.h
>
21
#include <
rex/settings_registry.h
>
22
#include <
rex/types.h
>
23
#include <
rex/utility.h
>
24
25
namespace
rex::apu
{
26
27
enum class
AudioStreamID : u32 {};
28
30
using
AudioFrame
= std::span<const f32, kAudioFrameSamples>;
31
32
struct
AudioStats
{
33
u32 open_streams = 0;
34
u32 queued_frames = 0;
35
u64
underruns
= 0;
36
u32
latency_us
= 0;
37
};
38
39
class
REX_APU_API
AudioSettings final :
public
SettingOwner
{
40
public
:
41
AudioSettings();
42
43
REX_SETTING(std::string, driver,
"sdl3"
,
44
"Audio driver, none for silence in an app that does not require audio"
, kStartupOnly);
45
REX_SETTING(
bool
, mute,
false
,
"Mute the audio output"
);
46
REX_SETTING(
bool
, mute_unfocused,
false
,
"Mute while the window does not have focus"
);
47
REX_SETTING(f64, gain, 1.0,
"Output gain, 1 is unity"
,
Range
{0.0, 4.0});
48
REX_SETTING(f64, center, 1.0,
"Center level on a surround device"
,
Range
{0.0, 2.0});
49
REX_SETTING(f64, surround, 1.0,
"Surround level on a surround device"
,
Range
{0.0, 2.0});
50
REX_SETTING(f64, lfe, 1.0,
"LFE level on a surround device"
,
Range
{0.0, 2.0});
51
REX_SETTING(f64, peak_limit, 0.0,
"Silence a stream that stays above this peak, 0 is off"
,
52
Range
{0.0, 8.0});
53
REX_SETTING(u32, max_queued_frames, 8,
"Frames a stream may queue"
,
Range
{4, 64}, kUntilLaunch);
54
};
55
64
REX_DECLARE_INTERFACE
(
IAudioSystem
, 1)
65
static constexpr u32 kMaxStreams = 8;
66
67
virtual
AudioSettings
& GetSettings() = 0;
68
75
[[nodiscard]] virtual
Result
<AudioStreamID> OpenStream(
76
MoveOnlyFunction
<
void
()> on_frame_played) = 0;
77
81
virtual
void
CloseStream(AudioStreamID stream) = 0;
82
88
[[nodiscard]] virtual
Result
<
void
> Submit(AudioStreamID stream,
AudioFrame
frame) = 0;
89
94
virtual u32 GetOutputChannels() const = 0;
95
99
virtual
AudioStats
GetStats() const = 0;
100
102
virtual
void
SetFocused(
bool
focused) = 0;
103
};
104
105
}
// namespace rex::apu
audio_driver.h
rex::SettingOwner::SettingOwner
SettingOwner(std::string_view scope)
rex::apu::AudioSettings
Definition
audio_system.h:39
rex::apu::IAudioSystem
Definition
audio_system.h:64
module.h
Interfaces, factory and module declaration.
REX_DECLARE_INTERFACE
#define REX_DECLARE_INTERFACE(Name, version)
Definition
module.h:114
rex::apu
Definition
app.h:41
rex::apu::AudioFrame
std::span< const f32, kAudioFrameSamples > AudioFrame
Definition
audio_system.h:30
rex::MoveOnlyFunction
typename detail::MoveOnlyFunctionFor< Signature >::type MoveOnlyFunction
Definition
utility.h:254
rex::Result
std::expected< T, Error > Result
Definition
result.h:98
platform.h
Platform flags, packing macros and export markers.
REX_APU_API
#define REX_APU_API
Definition
platform.h:211
result.h
setting.h
Typed settings and the owners that declare them.
settings_registry.h
The registry of every registered setting.
rex::Range
Definition
setting.h:78
rex::apu::AudioStats
Definition
audio_system.h:32
rex::apu::AudioStats::underruns
u64 underruns
Definition
audio_system.h:35
rex::apu::AudioStats::latency_us
u32 latency_us
Definition
audio_system.h:36
types.h
Integer types, byte order wrappers and size literals.
utility.h
Move only function, const propagating pointer and scope guard.
rex
apu
audio_system.h
Generated by
1.18.0