My Project
Loading...
Searching...
No Matches
CAudioDevice.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \version 3.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CAudioDeviceH
46#define CAudioDeviceH
47//------------------------------------------------------------------------------
48#include "audio/CAudioBuffer.h"
49#include "audio/CAudioSource.h"
50//------------------------------------------------------------------------------
51#include <vector>
52//------------------------------------------------------------------------------
53
54//------------------------------------------------------------------------------
55namespace chai3d {
56//------------------------------------------------------------------------------
57
58//==============================================================================
65//==============================================================================
66
67//==============================================================================
80//==============================================================================
82{
83 //--------------------------------------------------------------------------
84 // CONSTRUCTOR & DESTRUCTOR:
85 //--------------------------------------------------------------------------
86
87public:
88
90 cAudioDevice(bool a_createAudioContext = true);
91
93 virtual ~cAudioDevice();
94
95
96 //--------------------------------------------------------------------------
97 // PUBLIC METHODS:
98 //--------------------------------------------------------------------------
99
100public:
101
103 bool setListenerPos(const cVector3d& a_listenerPos);
104
107
109 bool setListenerRot(const cMatrix3d& a_listenerRot);
110
112 bool setListenerRot(const cVector3d& a_lookAt, const cVector3d& a_up);
113
116
118 bool setListenerVel(const cVector3d& a_listenerVel);
119
122
123
124 //--------------------------------------------------------------------------
125 // PROTECTED METHODS:
126 //--------------------------------------------------------------------------
127
128protected:
129
131 bool open();
132
134 bool close();
135
137 bool checkError();
138
139
140 //--------------------------------------------------------------------------
141 // PROTECTED MEMBERS:
142 //--------------------------------------------------------------------------
143
144protected:
145
147 void* m_device;
148
151
154
157
160
163
166};
167
168//------------------------------------------------------------------------------
169} // namespace chai3d
170//------------------------------------------------------------------------------
171
172//------------------------------------------------------------------------------
173#endif
174//------------------------------------------------------------------------------
Implements an audio Buffer.
Implements of an audio source.
This class implements an audio device context.
Definition CAudioDevice.h:82
cVector3d getListenerVel()
This method sets the linear velocity of the listener in world coordinates.
Definition CAudioDevice.h:121
void * m_context
Audio context (of type ALCcontext*).
Definition CAudioDevice.h:150
cVector3d m_listenerVel
Linear velocity of listener in world coordinates.
Definition CAudioDevice.h:159
bool checkError()
This method checks for any OpenAL errors.
Definition CAudioDevice.cpp:313
bool close()
This method closes this audio device context.
Definition CAudioDevice.cpp:148
virtual ~cAudioDevice()
Destructor of cAudioDevice.
Definition CAudioDevice.cpp:89
cVector3d getListenerPos()
This method returns the position of the listener in world coordinates.
Definition CAudioDevice.h:106
bool m_createAudioContext
Flag which indicates if this audio device has created an audio context.
Definition CAudioDevice.h:165
void * m_device
Audio device (of type ALCdevice*).
Definition CAudioDevice.h:147
bool setListenerRot(const cMatrix3d &a_listenerRot)
This method sets the orientation of the listener in world coordinates.
Definition CAudioDevice.cpp:222
bool m_active
Flag that indicates if the connection to audio device was opened successfully by calling method open(...
Definition CAudioDevice.h:162
cVector3d m_listenerPos
Position of listener in world coordinates.
Definition CAudioDevice.h:153
cMatrix3d getListenerRot()
This method returns the position of the listener in world coordinates.
Definition CAudioDevice.h:115
bool setListenerPos(const cVector3d &a_listenerPos)
This method sets the position of the listener in world coordinates.
Definition CAudioDevice.cpp:189
cMatrix3d m_listenerRot
Orientation of listener in world coordinates.
Definition CAudioDevice.h:156
bool open()
This method opens this audio device context.
Definition CAudioDevice.cpp:103
bool setListenerVel(const cVector3d &a_listenerVel)
This method sets the linear velocity of the listener in world coordinates.
Definition CAudioDevice.cpp:282
Definition CAudioBuffer.cpp:57
This class implements a 3D matrix.
Definition CMatrix3d.h:98
This class implements a 3D vector.
Definition CVector3d.h:89