diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2012-12-29 15:01:57 +0100 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2012-12-29 15:01:57 +0100 |
commit | a134cb75c5dd2570b9aeb1530701086d4f3f593d (patch) | |
tree | d5b1b158fb0d53b612b860013102126394ff6cc2 /src/sound | |
parent | cf65681f8029c2c1e5f18cc3776bdb09c8bd1db0 (diff) | |
download | colobot-a134cb75c5dd2570b9aeb1530701086d4f3f593d.tar.gz colobot-a134cb75c5dd2570b9aeb1530701086d4f3f593d.tar.bz2 colobot-a134cb75c5dd2570b9aeb1530701086d4f3f593d.zip |
Merge of master and dev
Diffstat (limited to 'src/sound')
-rw-r--r-- | src/sound/oalsound/alsound.cpp | 14 | ||||
-rw-r--r-- | src/sound/oalsound/channel.cpp | 24 | ||||
-rw-r--r-- | src/sound/sound.h | 2 |
3 files changed, 21 insertions, 19 deletions
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 0201417..f683a62 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -296,6 +296,8 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc GetLogger()->Warn("Sound %d was not loaded!\n", sound); return -1; } + + GetLogger()->Trace("ALSound::Play sound: %d volume: %f frequency: %f\n", sound, amplitude, frequency); int channel; bool bAlreadyLoaded; @@ -308,12 +310,12 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc Position(channel, pos); // setting initial values - mChannels[channel]->SetStartAmplitude(amplitude); + mChannels[channel]->SetStartAmplitude(mAudioVolume); mChannels[channel]->SetStartFrequency(frequency); mChannels[channel]->SetChangeFrequency(1.0f); mChannels[channel]->ResetOper(); - mChannels[channel]->AdjustFrequency(frequency); - mChannels[channel]->AdjustVolume(mAudioVolume); + mChannels[channel]->AdjustFrequency(frequency); + mChannels[channel]->AdjustVolume(amplitude * mAudioVolume); mChannels[channel]->Play(); return channel; } @@ -451,17 +453,17 @@ void ALSound::FrameMove(float delta) it.second->AdjustVolume(volume * mAudioVolume); // setting frequency - frequency = progress * (oper.finalFrequency - it.second->GetStartFrequency()) * it.second->GetStartFrequency() * it.second->GetChangeFrequency(); + frequency = progress * abs(oper.finalFrequency - it.second->GetStartFrequency()) * it.second->GetStartFrequency() * it.second->GetChangeFrequency(); it.second->AdjustFrequency(frequency); if (it.second->GetEnvelope().totalTime <= it.second->GetCurrentTime()) { if (oper.nextOper == SOPER_LOOP) { - GetLogger()->Trace("Sound oper: replay.\n"); + GetLogger()->Trace("ALSound::FrameMove oper: replay.\n"); it.second->SetCurrentTime(0.0f); it.second->Play(); } else { - GetLogger()->Trace("Sound oper: next.\n"); + GetLogger()->Trace("ALSound::FrameMove oper: next.\n"); it.second->SetStartAmplitude(oper.finalAmplitude); it.second->SetStartFrequency(oper.finalFrequency); it.second->PopEnvelope(); diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index 2285414..7d8244b 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -39,7 +39,7 @@ Channel::~Channel() { alSourcei(mSource, AL_BUFFER, 0); alDeleteSources(1, &mSource); if (alCheck()) - GetLogger()->Warn("Failed to delete sound source. Code: %s\n", alGetCode()); + GetLogger()->Warn("Failed to delete sound source. Code: %d\n", alGetCode()); } } @@ -50,7 +50,7 @@ bool Channel::Play() { alSourcePlay(mSource); if (alCheck()) - GetLogger()->Warn("Could not play audio sound source. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not play audio sound source. Code: %d\n", alGetCode()); return true; } @@ -61,7 +61,7 @@ bool Channel::SetPosition(Math::Vector pos) { alSource3f(mSource, AL_POSITION, pos.x, pos.y, pos.z); if (alCheck()) { - GetLogger()->Warn("Could not set sound position. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not set sound position. Code: %d\n", alGetCode()); return false; } return true; @@ -75,7 +75,7 @@ bool Channel::SetFrequency(float freq) alSourcef(mSource, AL_PITCH, freq); if (alCheck()) { - GetLogger()->Warn("Could not set sound pitch. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode()); return false; } return true; @@ -90,7 +90,7 @@ float Channel::GetFrequency() alGetSourcef(mSource, AL_PITCH, &freq); if (alCheck()) { - GetLogger()->Warn("Could not get sound pitch. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not get sound pitch. Code: %d\n", alGetCode()); return 0; } @@ -105,7 +105,7 @@ bool Channel::SetVolume(float vol) alSourcef(mSource, AL_GAIN, vol / MAXVOLUME); if (alCheck()) { - GetLogger()->Warn("Could not set sound volume. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode()); return false; } return true; @@ -120,7 +120,7 @@ float Channel::GetVolume() alGetSourcef(mSource, AL_GAIN, &vol); if (alCheck()) { - GetLogger()->Warn("Could not get sound volume. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not get sound volume. Code: %d\n", alGetCode()); return 0; } @@ -213,7 +213,7 @@ bool Channel::SetBuffer(Buffer *buffer) { mBuffer = buffer; alSourcei(mSource, AL_BUFFER, buffer->GetBuffer()); if (alCheck()) { - GetLogger()->Warn("Could not set sound buffer. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not set sound buffer. Code: %d\n", alGetCode()); return false; } mInitFrequency = GetFrequency(); @@ -237,7 +237,7 @@ bool Channel::IsPlaying() { alGetSourcei(mSource, AL_SOURCE_STATE, &status); if (alCheck()) { - GetLogger()->Warn("Could not get sound status. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not get sound status. Code: %d\n", alGetCode()); return false; } @@ -253,7 +253,7 @@ bool Channel::IsReady() { bool Channel::Stop() { alSourceStop(mSource); if (alCheck()) { - GetLogger()->Warn("Could not stop sound. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not stop sound. Code: %d\n", alGetCode()); return false; } return true; @@ -265,7 +265,7 @@ float Channel::GetCurrentTime() ALfloat current; alGetSourcef(mSource, AL_SEC_OFFSET, ¤t); if (alCheck()) { - GetLogger()->Warn("Could not get source current play time. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode()); return 0.0f; } return current; @@ -276,7 +276,7 @@ void Channel::SetCurrentTime(float current) { alSourcef(mSource, AL_SEC_OFFSET, current); if (alCheck()) - GetLogger()->Warn("Could not get source current play time. Code: %s\n", alGetCode()); + GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode()); } diff --git a/src/sound/sound.h b/src/sound/sound.h index 566f415..518e2ad 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -168,7 +168,7 @@ class CSoundInterface * Function calls \link CSoundInterface::Cache() \endlink for each file */ inline void CacheAll(std::string path) { - for ( int i = 1; i < 69; i++ ) { + for ( int i = 1; i <= 81; i++ ) { std::stringstream filename; filename << path << "/sound" << std::setfill('0') << std::setw(3) << i << ".wav"; if ( !Cache(static_cast<Sound>(i), filename.str()) ) |