nomlib
Loading...
Searching...
No Matches
IOAudioEngine.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_IO_AUDIO_ENGINE_HPP
30#define NOMLIB_AUDIO_IO_AUDIO_ENGINE_HPP
31
32#include "nomlib/config.hpp"
33#include "nomlib/math/Point3.hpp"
34
35namespace nom {
36namespace audio {
37
38// Forward declarations
39struct SoundBuffer;
40
49
50// TODO(jeff): Add const to getters!
51class IOAudioEngine
52{
53 protected:
54 IOAudioEngine()
55 {
56 NOM_LOG_TRACE_PRIO(NOM_LOG_CATEGORY_TRACE_AUDIO,
57 NOM_LOG_PRIORITY_VERBOSE);
58 }
59
60 public:
61 virtual ~IOAudioEngine()
62 {
63 NOM_LOG_TRACE_PRIO(NOM_LOG_CATEGORY_TRACE_AUDIO,
64 NOM_LOG_PRIORITY_VERBOSE);
65 }
66
67 virtual void init(void* driver) = 0;
68
69 virtual bool valid() const = 0;
70
71 // virtual int sample_rate() const = 0;
72 // virtual int mono_sources() const = 0;
73 // virtual int stereo_sources() const = 0;
74
75 virtual uint32 caps() const = 0;
76 virtual void set_cap(uint32 format) = 0;
77
78 virtual bool connected() const = 0;
79
80 virtual
81 uint32 channel_format(uint32 num_channels, uint32 channel_format) = 0;
82
83 virtual bool valid_buffer(SoundBuffer* buffer) = 0;
84 virtual bool valid_source(SoundBuffer* buffer) = 0;
85
86 virtual uint32 state(SoundBuffer* target) = 0;
87 virtual real32 pitch(SoundBuffer* target) = 0;
88
89 virtual real32 volume() const = 0;
90 virtual Point3f position() const = 0;
91
92 virtual real32 volume(SoundBuffer* buffer) const = 0;
93 virtual real32 min_volume(SoundBuffer* buffer) = 0;
94 virtual real32 max_volume(SoundBuffer* buffer) = 0;
95
96 virtual Point3f velocity(SoundBuffer* buffer) = 0;
97 virtual Point3f position(SoundBuffer* buffer) = 0;
98 virtual real32 playback_position(SoundBuffer* buffer) = 0;
99 virtual real32 playback_samples(SoundBuffer* buffer) = 0;
100
101 // virtual void set_state(SoundBuffer* target, uint32 state) = 0;
102
103 virtual void set_volume(real32 gain) = 0;
104 virtual void set_position(const Point3f& p) = 0;
105
106 virtual void set_volume(SoundBuffer* target, real32 gain) = 0;
107 virtual void set_min_volume(SoundBuffer* target, real32 gain) = 0;
108 virtual void set_max_volume(SoundBuffer* target, real32 gain) = 0;
109
110 virtual void set_velocity(SoundBuffer* target, const Point3f& v) = 0;
111 virtual void set_position(SoundBuffer* target, const Point3f& p) = 0;
112 virtual void set_pitch(SoundBuffer* target, real32 pitch) = 0;
113 virtual void set_playback_position(SoundBuffer* target, real32 offset_seconds) = 0;
114 virtual void play(SoundBuffer* target) = 0;
115 virtual void stop(SoundBuffer* target) = 0;
116 virtual void pause(SoundBuffer* target) = 0;
117 virtual void resume(SoundBuffer* target) = 0;
118
119 virtual bool push_buffer(SoundBuffer* buffer) = 0;
120 virtual bool queue_buffer(SoundBuffer* buffer) = 0;
121
122 virtual void suspend() = 0;
123 virtual void resume() = 0;
124 virtual void close() = 0;
125
126 virtual void free_buffer(SoundBuffer* buffer) = 0;
127};
128
129} // namespace audio
130} // namespace nom
131
132#endif // include guard defined