Refactored Math::Vector in sound implementation
parent
55f5d25c95
commit
da2471567d
|
@ -316,15 +316,15 @@ bool CALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoad
|
|||
|
||||
int CALSound::Play(SoundType sound, float amplitude, float frequency, bool loop)
|
||||
{
|
||||
return Play(sound, Math::Vector{}, true, amplitude, frequency, loop);
|
||||
return Play(sound, glm::vec3{0, 0, 0}, true, amplitude, frequency, loop);
|
||||
}
|
||||
|
||||
int CALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop)
|
||||
int CALSound::Play(SoundType sound, const glm::vec3 &pos, float amplitude, float frequency, bool loop)
|
||||
{
|
||||
return Play(sound, pos, false, amplitude, frequency, loop);
|
||||
}
|
||||
|
||||
int CALSound::Play(SoundType sound, const Math::Vector &pos, bool relativeToListener, float amplitude, float frequency, bool loop)
|
||||
int CALSound::Play(SoundType sound, const glm::vec3 &pos, bool relativeToListener, float amplitude, float frequency, bool loop)
|
||||
{
|
||||
if (!m_enabled)
|
||||
{
|
||||
|
@ -408,7 +408,7 @@ bool CALSound::AddEnvelope(int channel, float amplitude, float frequency, float
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CALSound::Position(int channel, const Math::Vector &pos)
|
||||
bool CALSound::Position(int channel, const glm::vec3 &pos)
|
||||
{
|
||||
if (!CheckChannel(channel))
|
||||
{
|
||||
|
@ -570,11 +570,11 @@ void CALSound::FrameMove(float rTime)
|
|||
}
|
||||
}
|
||||
|
||||
void CALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
|
||||
void CALSound::SetListener(const glm::vec3 &eye, const glm::vec3 &lookat)
|
||||
{
|
||||
m_eye = eye;
|
||||
m_lookat = lookat;
|
||||
Math::Vector forward = glm::normalize(lookat - eye);
|
||||
glm::vec3 forward = glm::normalize(lookat - eye);
|
||||
float orientation[] = {forward.x, forward.y, forward.z, 0.f, -1.0f, 0.0f};
|
||||
|
||||
alListener3f(AL_POSITION, eye.x, eye.y, eye.z);
|
||||
|
|
|
@ -96,14 +96,14 @@ public:
|
|||
void SetMusicVolume(int volume) override;
|
||||
int GetMusicVolume() override;
|
||||
|
||||
void SetListener(const Math::Vector &eye, const Math::Vector &lookat) override;
|
||||
void SetListener(const glm::vec3 &eye, const glm::vec3 &lookat) override;
|
||||
void FrameMove(float rTime) override;
|
||||
|
||||
int Play(SoundType sound, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override;
|
||||
int Play(SoundType sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override;
|
||||
int Play(SoundType sound, const glm::vec3 &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override;
|
||||
bool FlushEnvelope(int channel) override;
|
||||
bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) override;
|
||||
bool Position(int channel, const Math::Vector &pos) override;
|
||||
bool Position(int channel, const glm::vec3 &pos) override;
|
||||
bool Frequency(int channel, float frequency) override;
|
||||
bool Stop(int channel) override;
|
||||
bool StopAll() override;
|
||||
|
@ -117,7 +117,7 @@ public:
|
|||
|
||||
private:
|
||||
void CleanUp();
|
||||
int Play(SoundType sound, const Math::Vector &pos, bool relativeToListener, float amplitude, float frequency, bool loop);
|
||||
int Play(SoundType sound, const glm::vec3 &pos, bool relativeToListener, float amplitude, float frequency, bool loop);
|
||||
int GetPriority(SoundType);
|
||||
bool SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded);
|
||||
bool CheckChannel(int &channel);
|
||||
|
@ -134,7 +134,7 @@ private:
|
|||
std::unique_ptr<CChannel> m_currentMusic;
|
||||
std::list<OldMusic> m_oldMusic;
|
||||
OldMusic m_previousMusic;
|
||||
Math::Vector m_eye;
|
||||
Math::Vector m_lookat;
|
||||
glm::vec3 m_eye;
|
||||
glm::vec3 m_lookat;
|
||||
CWorkerThread m_thread;
|
||||
};
|
||||
|
|
|
@ -94,7 +94,7 @@ bool CChannel::Pause()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CChannel::SetPosition(const Math::Vector &pos, bool relativeToListener)
|
||||
bool CChannel::SetPosition(const glm::vec3 &pos, bool relativeToListener)
|
||||
{
|
||||
if (!m_ready || m_buffer == nullptr)
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
bool Pause();
|
||||
bool Stop();
|
||||
|
||||
bool SetPosition(const Math::Vector &pos, bool relativeToListener = false);
|
||||
bool SetPosition(const glm::vec3 &pos, bool relativeToListener = false);
|
||||
|
||||
bool SetFrequency(float freq);
|
||||
float GetFrequency();
|
||||
|
@ -120,6 +120,6 @@ private:
|
|||
bool m_ready;
|
||||
bool m_loop;
|
||||
bool m_mute;
|
||||
Math::Vector m_position;
|
||||
glm::vec3 m_position;
|
||||
};
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ int CSoundInterface::GetMusicVolume()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CSoundInterface::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
|
||||
void CSoundInterface::SetListener(const glm::vec3 &eye, const glm::vec3 &lookat)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ int CSoundInterface::Play(SoundType sound, float amplitude, float frequency, boo
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CSoundInterface::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop)
|
||||
int CSoundInterface::Play(SoundType sound, const glm::vec3 &pos, float amplitude, float frequency, bool loop)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ bool CSoundInterface::AddEnvelope(int channel, float amplitude, float frequency,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CSoundInterface::Position(int channel, const Math::Vector &pos)
|
||||
bool CSoundInterface::Position(int channel, const glm::vec3 &pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
* \param eye - position of listener
|
||||
* \param lookat - direction listener is looking at
|
||||
*/
|
||||
virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat);
|
||||
virtual void SetListener(const glm::vec3 &eye, const glm::vec3 &lookat);
|
||||
|
||||
/** Update data each frame
|
||||
* \param rTime - time since last update
|
||||
|
@ -153,7 +153,7 @@ public:
|
|||
* \param loop - loop sound
|
||||
* \return identifier of channel that sound will be played on
|
||||
*/
|
||||
virtual int Play(SoundType sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
|
||||
virtual int Play(SoundType sound, const glm::vec3 &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
|
||||
|
||||
/** Remove all operations that would be made on sound in channel.
|
||||
* \param channel - channel to work on
|
||||
|
@ -176,7 +176,7 @@ public:
|
|||
* \param pos - new positino of a sound
|
||||
* \return return true on success
|
||||
*/
|
||||
virtual bool Position(int channel, const Math::Vector &pos);
|
||||
virtual bool Position(int channel, const glm::vec3 &pos);
|
||||
|
||||
/** Set sound frequency
|
||||
* \param channel - channel to work on
|
||||
|
|
Loading…
Reference in New Issue