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 <nomlib/types.hpp>
33
34namespace nom {
35namespace audio {
36
37// Forward declarations
38// struct IAudioDevice;
39class IOAudioEngine;
40
41// exposed to the end-user as 0.0f .. 100.0f
42// internally stored as a 32-bit floating-point value that is normalized to 0..1
43const nom::real32 MIN_VOLUME = 0.0f;
44const nom::real32 MAX_VOLUME = 100.0f;
45
47const nom::uint32 BUFFER_SIZE = kilobyte(32);
48const nom::size_type TOTAL_NUM_BUFFERS = 32;
49const nom::size_type TOTAL_NUM_MONO_SOURCES = 128;
50const nom::size_type TOTAL_NUM_STEREO_SOURCES = 127;
51const nom::size_type TOTAL_NUM_SOURCES =
52 TOTAL_NUM_MONO_SOURCES + TOTAL_NUM_STEREO_SOURCES;
53
54// TODO(jeff): Collapse with nom::audio::AudioFormat..?
55enum AudioCaps
56{
57 CAPS_UNDEFINED = 0x0000,
58
59 CAPS_FORMAT_MONO_S8 = 0x1000,
60 CAPS_FORMAT_STEREO_S8 = 0x1002,
61 CAPS_FORMAT_QUAD_S8 = 0x1004,
62 CAPS_FORMAT_51CHN_S8 = 0x1006,
63 CAPS_FORMAT_61CHN_S8 = 0x1008,
64 CAPS_FORMAT_71CHN_S8 = 0x1010,
65
66 CAPS_FORMAT_MONO_U8 = 0x1100,
67 CAPS_FORMAT_STEREO_U8 = 0x1102,
68 CAPS_FORMAT_QUAD_U8 = 0x1104,
69 CAPS_FORMAT_51CHN_U8 = 0x1106,
70 CAPS_FORMAT_61CHN_U8 = 0x1108,
71 CAPS_FORMAT_71CHN_U8 = 0x1110,
72
73 CAPS_FORMAT_MONO_S16 = 0x1200,
74 CAPS_FORMAT_STEREO_S16 = 0x1202,
75 CAPS_FORMAT_QUAD_S16 = 0x1204,
76 CAPS_FORMAT_51CHN_S16 = 0x1206,
77 CAPS_FORMAT_61CHN_S16 = 0x1208,
78 CAPS_FORMAT_71CHN_S16 = 0x1210,
79
80 CAPS_FORMAT_MONO_S24 = 0x1300,
81 CAPS_FORMAT_STEREO_S24 = 0x1302,
82 CAPS_FORMAT_QUAD_S24 = 0x1304,
83 CAPS_FORMAT_51CHN_S24 = 0x1306,
84 CAPS_FORMAT_61CHN_S24 = 0x1308,
85 CAPS_FORMAT_71CHN_S24 = 0x1310,
86
87 CAPS_FORMAT_MONO_S32 = 0x1400,
88 CAPS_FORMAT_STEREO_S32 = 0x1402,
89 CAPS_FORMAT_QUAD_S32 = 0x1404,
90 CAPS_FORMAT_51CHN_S32 = 0x1406,
91 CAPS_FORMAT_61CHN_S32 = 0x1408,
92 CAPS_FORMAT_71CHN_S32 = 0x1410,
93
94 CAPS_FORMAT_MONO_FLOAT32 = 0x1500,
95 CAPS_FORMAT_STEREO_FLOAT32 = 0x1502,
96 CAPS_FORMAT_QUAD_R32 = 0x1504,
97
98 CAPS_FORMAT_MONO_FLOAT64 = 0x1600,
99 CAPS_FORMAT_STEREO_FLOAT64 = 0x1602,
100 CAPS_FORMAT_QUAD_R64 = 0x1604,
101
102 // CAPS_MAC_STATIC_BUFFER,
103 // CAPS_MAC_EXT,
104 // CAPS_EAX,
105 // CAPS_EFX,
106 // CAPS_XRAM,
107};
108
109enum AudioSpecFlags: uint32
110{
111 AUDIO_SPEC_UNDEFINED = 0x00000,
112
115 // AUDIO_SPEC_ASYNC = 0x00100,
116 AUDIO_SPEC_CAPTURE = 0x00200,
117 // AUDIO_SPEC_STATIC_BUFFER,
118 // AUDIO_SPEC_SOURCE_NOTIFICATION,
119};
120
122{
123 // audio front-end
124 // IAudioDevice* dev = nullptr;
125
126 // audio back-end
127 // IOAudioEngine* engine = nullptr;
128
129 // audio device name
130 const char* name = nullptr;
131
132 // audio back-end
133 const char* engine = nullptr;
134
136 int sample_rate = 44100;
137
140 int num_mono_sources = audio::TOTAL_NUM_MONO_SOURCES;
141
144 int num_stereo_sources = audio::TOTAL_NUM_STEREO_SOURCES;
145
148
151 bool sync_context = false;
152
155 uint32 flags = 0;
156
157 // uint32 channel_format = 0;
158};
159
160} // namespace audio
161} // namespace nom
162
163#endif // include guard defined
Abstract base class for an instance of the audio hardware interface.
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 flags
One or more bit-masked enumeration values from audio::AudioSpecFlags.
int num_mono_sources
A request for a specific number of mono (one channel) sources to be allocated at the time of an audio...