11#include < cstring>
22#include " audio_system.h"
33#include " file_system.h"
4- // #include "audio_source .h"
4+ #include " audio_listener .h"
55#include " AL/alure.h"
66
7- float AudioSystem::m_listenerPos[3 ] = {};
8- float AudioSystem::m_listenerOri[6 ] = {0 , 0 , -1 , 0 , 1 , 0 };
9- float AudioSystem::m_listenerVel[3 ] = {};
7+
108std::vector<AudioSource*> AudioSystem::audioSources;
119std::vector<AudioBuffer*> AudioSystem::audioBuffers;
1210
@@ -116,9 +114,7 @@ void AudioSystem::Init()
116114 write_callback,
117115 seek_callback);
118116
119- alListenerfv (AL_POSITION, m_listenerPos);
120- alListenerfv (AL_ORIENTATION, m_listenerOri);
121- alListenerfv (AL_VELOCITY, m_listenerVel);
117+ AudioListener::Init ();
122118}
123119
124120void AudioSystem::Deinit ()
@@ -145,76 +141,6 @@ void AudioSystem::DeleteAllSources()
145141 audioSources.clear ();
146142}
147143
148- void AudioSystem::SetListenerPosition (float * position)
149- {
150- memcpy (m_listenerPos, position, sizeof (float ) * 3 );
151- alListenerfv (AL_POSITION, position);
152- }
153-
154- void AudioSystem::SetListenerOrientation (float * orientation)
155- {
156- memcpy (m_listenerOri, orientation, sizeof (float ) * 6 );
157- alListenerfv (AL_ORIENTATION, orientation);
158- }
159-
160- void AudioSystem::SetListenerVelocity (float * velocity)
161- {
162- memcpy (m_listenerVel, velocity, sizeof (float ) * 3 );
163- alListenerfv (AL_VELOCITY, velocity);
164- }
165-
166- void AudioSystem::SetListenerPosition (float x, float y, float z)
167- {
168- m_listenerPos[0 ] = x;
169- m_listenerPos[1 ] = y;
170- m_listenerPos[2 ] = z;
171- alListenerfv (AL_POSITION, m_listenerPos);
172- }
173-
174- void AudioSystem::SetListenerOrientation (float tX, float tY, float tZ,
175- float uX, float uY, float uZ)
176- {
177- m_listenerOri[0 ] = tX;
178- m_listenerOri[1 ] = tY;
179- m_listenerOri[2 ] = tZ;
180- m_listenerOri[3 ] = uX;
181- m_listenerOri[4 ] = uY;
182- m_listenerOri[5 ] = uZ;
183- alListenerfv (AL_ORIENTATION, m_listenerOri);
184- }
185-
186- void AudioSystem::SetListenerVelocity (float x, float y, float z)
187- {
188- m_listenerVel[0 ] = x;
189- m_listenerVel[1 ] = y;
190- m_listenerVel[2 ] = z;
191- alListenerfv (AL_VELOCITY, m_listenerVel);
192- }
193-
194- void AudioSystem::GetListenerPosition (float * position)
195- {
196- if (position)
197- {
198- memcpy (position, m_listenerPos, 3 * sizeof (float ));
199- }
200- }
201-
202- void AudioSystem::GetListenerOrientation (float * orientation)
203- {
204- if (orientation)
205- {
206- memcpy (orientation, m_listenerOri, 6 * sizeof (float ));
207- }
208- }
209-
210- void AudioSystem::GetListenerVelocity (float * velocity)
211- {
212- if (velocity)
213- {
214- memcpy (velocity, m_listenerVel, 3 * sizeof (float ));
215- }
216- }
217-
218144void AudioSystem::Update ()
219145{
220146 for (auto source : audioSources)
0 commit comments