From fe3f9ea38cfae89fdd83d4c3fe79ea355f50bce9 Mon Sep 17 00:00:00 2001 From: erihel Date: Thu, 19 Dec 2013 22:41:16 +0100 Subject: Sound support changes * removed 2d sound * fixed listener orientation (propably issue #235) * removed unused code and minor refactoring --- src/sound/oalsound/channel.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'src/sound/oalsound/channel.cpp') diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index 4d89df5..b053316 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -75,7 +75,7 @@ bool Channel::Play() } -bool Channel::SetPan(Math::Vector pos) +bool Channel::SetPosition(const Math::Vector &pos) { if (!m_ready || m_buffer == nullptr) { @@ -92,18 +92,6 @@ bool Channel::SetPan(Math::Vector pos) } -void Channel::SetPosition(Math::Vector pos) -{ - m_position = pos; -} - - -Math::Vector Channel::GetPosition() -{ - return m_position; -} - - bool Channel::SetFrequency(float freq) { if (!m_ready || m_buffer == nullptr) -- cgit v1.2.3-1-g7c22 From 999490e88bc699b671b94b88c9a4327d963db378 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 31 Dec 2013 16:58:21 +0100 Subject: Code for changing music in pause mode As requested by @Emxx52. Only code for now, we don't have the music yet. Temporairly in developements builds music will change to Prototype (in CBot editor) and Constructive Destruction (in SatCom) --- src/sound/oalsound/channel.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/sound/oalsound/channel.cpp') diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index b053316..e58ab54 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -74,6 +74,21 @@ bool Channel::Play() return true; } +bool Channel::Pause() +{ + if(!m_ready || !IsPlaying()) + { + return false; + } + + alSourcePause(m_source); + if (alCheck()) + { + GetLogger()->Warn("Could not pause audio sound source. Code: %d\n", alGetCode()); + } + return true; +} + bool Channel::SetPosition(const Math::Vector &pos) { -- cgit v1.2.3-1-g7c22 From c5ae2610b57e54216ee55214bd74368c9c7e22ee Mon Sep 17 00:00:00 2001 From: erihel Date: Sat, 18 Jan 2014 03:42:07 +0100 Subject: Minor changes to sound support. * changed channel limit from 64 to 2048 that will decrease if error is found while trying to play sound * added id to each channel to avoid collisions when more than 1 object tries to modify a sound * minor formatting changes --- src/sound/oalsound/channel.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/sound/oalsound/channel.cpp') diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index e58ab54..7021c2f 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -23,7 +23,7 @@ Channel::Channel() if (alCheck()) { - GetLogger()->Warn("Failed to create sound source. Code: %d\n", alGetCode()); + GetLogger()->Debug("Failed to create sound source. Code: %d\n", alGetCode()); m_ready = false; } else @@ -40,6 +40,7 @@ Channel::Channel() m_startFrequency = 0.0f; m_changeFrequency = 0.0f; m_volume = 0.0f; + m_id = 0; } @@ -51,7 +52,7 @@ Channel::~Channel() alSourcei(m_source, AL_BUFFER, 0); alDeleteSources(1, &m_source); if (alCheck()) - GetLogger()->Warn("Failed to delete sound source. Code: %d\n", alGetCode()); + GetLogger()->Debug("Failed to delete sound source. Code: %d\n", alGetCode()); } } @@ -69,7 +70,7 @@ bool Channel::Play() alSourcePlay(m_source); if (alCheck()) { - GetLogger()->Warn("Could not play audio sound source. Code: %d\n", alGetCode()); + GetLogger()->Debug("Could not play audio sound source. Code: %d\n", alGetCode()); } return true; } @@ -84,7 +85,7 @@ bool Channel::Pause() alSourcePause(m_source); if (alCheck()) { - GetLogger()->Warn("Could not pause audio sound source. Code: %d\n", alGetCode()); + GetLogger()->Debug("Could not pause audio sound source. Code: %d\n", alGetCode()); } return true; } @@ -100,7 +101,7 @@ bool Channel::SetPosition(const Math::Vector &pos) alSource3f(m_source, AL_POSITION, pos.x, pos.y, pos.z); if (alCheck()) { - GetLogger()->Warn("Could not set sound position. Code: %d\n", alGetCode()); + GetLogger()->Debug("Could not set sound position. Code: %d\n", alGetCode()); return false; } return true; @@ -117,7 +118,7 @@ bool Channel::SetFrequency(float freq) alSourcef(m_source, AL_PITCH, freq); if (alCheck()) { - GetLogger()->Warn("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode()); + GetLogger()->Debug("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode()); return false; } return true; @@ -135,7 +136,7 @@ float Channel::GetFrequency() alGetSourcef(m_source, AL_PITCH, &freq); if (alCheck()) { - GetLogger()->Warn("Could not get sound pitch. Code: %d\n", alGetCode()); + GetLogger()->Debug("Could not get sound pitch. Code: %d\n", alGetCode()); return 0; } @@ -153,7 +154,7 @@ bool Channel::SetVolume(float vol) alSourcef(m_source, AL_GAIN, vol); if (alCheck()) { - GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode()); + GetLogger()->Debug("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode()); return false; } return true; @@ -171,7 +172,7 @@ float Channel::GetVolume() alGetSourcef(m_source, AL_GAIN, &vol); if (alCheck()) { - GetLogger()->Warn("Could not get sound volume. Code: %d\n", alGetCode()); + GetLogger()->Debug("Could not get sound volume. Code: %d\n", alGetCode()); return 0; } @@ -434,3 +435,15 @@ bool Channel::IsMuted() return m_mute; } + +void Channel::Reset() +{ + m_id++; +} + + +int Channel::GetId() +{ + return m_id; +} + -- cgit v1.2.3-1-g7c22