nomlib
Loading...
Searching...
No Matches
audio_defs.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014, 2015, 2016 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_AUDIO_DEFINITIONS_HPP
30#define NOMLIB_AUDIO_DEFINITIONS_HPP
31
32#include "export.hpp"
33#include <nomlib/types.hpp>
34
35namespace nom {
36namespace audio {
37
38// Forward declarations
39// struct IAudioDevice;
40class IOAudioEngine;
41
42// exposed to the end-user as 0.0f .. 100.0f
43// internally stored as a 32-bit floating-point value that is normalized to 0..1
44const nom::real32 MIN_VOLUME = 0.0f;
45const nom::real32 MAX_VOLUME = 100.0f;
46
48const nom::uint32 BUFFER_SIZE = kilobyte(32);
49const nom::size_type TOTAL_NUM_BUFFERS = 32;
50const nom::size_type TOTAL_NUM_MONO_SOURCES = 128;
51const nom::size_type TOTAL_NUM_STEREO_SOURCES = 127;
52const nom::size_type TOTAL_NUM_SOURCES =
53 TOTAL_NUM_MONO_SOURCES + TOTAL_NUM_STEREO_SOURCES;
54
55// TODO(jeff): Collapse with nom::audio::AudioFormat..?
56enum NOM_EXPORT AudioCaps
57{
58 CAPS_UNDEFINED = 0x0000,
59
60 CAPS_FORMAT_MONO_S8 = 0x1000,
61 CAPS_FORMAT_STEREO_S8 = 0x1002,
62 CAPS_FORMAT_QUAD_S8 = 0x1004,
63 CAPS_FORMAT_51CHN_S8 = 0x1006,
64 CAPS_FORMAT_61CHN_S8 = 0x1008,
65 CAPS_FORMAT_71CHN_S8 = 0x1010,
66
67 CAPS_FORMAT_MONO_U8 = 0x1100,
68 CAPS_FORMAT_STEREO_U8 = 0x1102,
69 CAPS_FORMAT_QUAD_U8 = 0x1104,
70 CAPS_FORMAT_51CHN_U8 = 0x1106,
71 CAPS_FORMAT_61CHN_U8 = 0x1108,
72 CAPS_FORMAT_71CHN_U8 = 0x1110,
73
74 CAPS_FORMAT_MONO_S16 = 0x1200,
75 CAPS_FORMAT_STEREO_S16 = 0x1202,
76 CAPS_FORMAT_QUAD_S16 = 0x1204,
77 CAPS_FORMAT_51CHN_S16 = 0x1206,
78 CAPS_FORMAT_61CHN_S16 = 0x1208,
79 CAPS_FORMAT_71CHN_S16 = 0x1210,
80
81 CAPS_FORMAT_MONO_S24 = 0x1300,
82 CAPS_FORMAT_STEREO_S24 = 0x1302,
83 CAPS_FORMAT_QUAD_S24 = 0x1304,
84 CAPS_FORMAT_51CHN_S24 = 0x1306,
85 CAPS_FORMAT_61CHN_S24 = 0x1308,
86 CAPS_FORMAT_71CHN_S24 = 0x1310,
87
88 CAPS_FORMAT_MONO_S32 = 0x1400,
89 CAPS_FORMAT_STEREO_S32 = 0x1402,
90 CAPS_FORMAT_QUAD_S32 = 0x1404,
91 CAPS_FORMAT_51CHN_S32 = 0x1406,
92 CAPS_FORMAT_61CHN_S32 = 0x1408,
93 CAPS_FORMAT_71CHN_S32 = 0x1410,
94
95 CAPS_FORMAT_MONO_FLOAT32 = 0x1500,
96 CAPS_FORMAT_STEREO_FLOAT32 = 0x1502,
97 CAPS_FORMAT_QUAD_R32 = 0x1504,
98
99 CAPS_FORMAT_MONO_FLOAT64 = 0x1600,
100 CAPS_FORMAT_STEREO_FLOAT64 = 0x1602,
101 CAPS_FORMAT_QUAD_R64 = 0x1604,
102
103 // CAPS_MAC_STATIC_BUFFER,
104 // CAPS_MAC_EXT,
105 // CAPS_EAX,
106 // CAPS_EFX,
107 // CAPS_XRAM,
108};
109
110enum NOM_EXPORT AudioSpecFlags: uint32
111{
112 AUDIO_SPEC_UNDEFINED = 0x00000,
113
116 // AUDIO_SPEC_ASYNC = 0x00100,
117 AUDIO_SPEC_CAPTURE = 0x00200,
118 // AUDIO_SPEC_STATIC_BUFFER,
119 // AUDIO_SPEC_SOURCE_NOTIFICATION,
120};
121
122struct NOM_EXPORT AudioSpec
123{
124 // audio front-end
125 // IAudioDevice* dev = nullptr;
126
127 // audio back-end
128 // IOAudioEngine* engine = nullptr;
129
130 // audio device name
131 const char* name = nullptr;
132
133 // audio back-end
134 const char* engine = nullptr;
135
137 int sample_rate = 44100;
138
141 int num_mono_sources = audio::TOTAL_NUM_MONO_SOURCES;
142
145 int num_stereo_sources = audio::TOTAL_NUM_STEREO_SOURCES;
146
149
152 bool sync_context = false;
153
157 uint32 fmt_flags = 0;
158 uint32 ctx_flags = 0;
159 uint32 ext_flags = 0;
160
161 // uint32 channel_format = 0;
162};
163
164} // namespace audio
165} // namespace nom
166
167#endif // include guard defined
int sample_rate
The final output audio frequency, specified in Hertz (Hz).
int num_stereo_sources
A request for a specified number of stereo (two channel) sources to be allocated at the time of an au...
bool sync_context
A request to the specified audio context that context processing occurs asynchronously where possible...
int refresh_rate
The update frequency, in Hertz (Hz), of audio context processing.
uint32 fmt_flags
One or more bit-masked enumeration values from audio::AudioSpecFlags. audio::AudioFormat.
int num_mono_sources
A request for a specific number of mono (one channel) sources to be allocated at the time of an audio...