Commit 9d2670eb authored by Gerhard Stein's avatar Gerhard Stein Committed by Gerhard Stein

Sound fixes

parent 5e9d2ef1
Subproject commit 56b1530f51d3a739fbdbf172bcddffd7ff8d6b38
Subproject commit 71d3bf24f8057f67d8d6bcd6f203d2f8df398074
......@@ -217,8 +217,8 @@ bool CSettings::loadDrvCfg()
Configuration.ReadInteger("Audio", "musicvol", &music_vol, SDL_MIX_MAXVOLUME);
Configuration.ReadInteger("Audio", "soundvol", &sound_vol, SDL_MIX_MAXVOLUME);
gSound.setMusicVolume(music_vol*8);
gSound.setSoundVolume(sound_vol*8);
gSound.setMusicVolume(Uint8(music_vol));
gSound.setSoundVolume(Uint8(sound_vol));
}
return true;
}
......
......@@ -88,8 +88,8 @@ void CAudioSettings::ponder(const float deltaT)
mSoundVolume = mpSoundVolume->getSelection();
gSound.setSoundVolume( mSoundVolume, true );
gSound.setMusicVolume( mpMusicVolume->getSelection(), true );
gSound.setSoundVolume( mSoundVolume );
gSound.setMusicVolume( mpMusicVolume->getSelection() );
}
......
......@@ -79,8 +79,8 @@ void CAudioSettings::ponder(const float deltaT)
mSoundVolume = mpSoundVolume->getSelection();
gSound.setSoundVolume( mSoundVolume, true );
gSound.setMusicVolume( mpMusicVolume->getSelection(), true );
gSound.setSoundVolume( mSoundVolume );
gSound.setMusicVolume( mpMusicVolume->getSelection() );
}
......
......@@ -256,23 +256,15 @@ void Audio::stopSound(const GameSound snd)
}
}
void Audio::setSoundVolume(const Uint8 volume, const bool immediately)
void Audio::setSoundVolume(const Uint8 volume)
{
m_SoundVolume = volume;
if(immediately)
{
Mix_Volume(-1, volume);
}
Mix_Volume(-1, volume);
}
void Audio::setMusicVolume(const Uint8 volume, const bool immediately)
void Audio::setMusicVolume(const Uint8 volume)
{
m_MusicVolume = volume;
if(immediately)
{
Mix_VolumeMusic(volume);
}
Mix_VolumeMusic(volume);
}
......@@ -407,6 +399,8 @@ void Audio::playStereosoundSlot(unsigned char slotplay,
sndChnl.setupSound(chosenSlot,
(mode==SoundPlayMode::PLAY_FORCE) ? true : false );
break;
}
}
}
......
......@@ -83,8 +83,8 @@ public:
void stopSound(const GameSound snd);
void destroy();
void setSoundVolume(const Uint8 volume, const bool immediately=false);
void setMusicVolume(const Uint8 volume, const bool immediately=false);
void setSoundVolume(const Uint8 volume);
void setMusicVolume(const Uint8 volume);
Uint8 getSoundVolume() { return m_SoundVolume; }
Uint8 getMusicVolume() { return m_MusicVolume; }
......
......@@ -138,8 +138,6 @@ void CMusic::play()
gLogging.ftextOut("Mix_PlayMusic: %s\n", Mix_GetError());
// well, there's no music, but most games don't break without music...
}
//Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
}
void CMusic::pause()
......
......@@ -16,6 +16,8 @@
#include <SDL_mixer.h>
#include "sdl/audio/Audio.h"
int CSoundChannel::mTotNumChannels = 0;
CSoundChannel::
......@@ -81,12 +83,16 @@ void CSoundChannel::setupSound( CSoundSlot &SndSlottoPlay,
auto waveChunk = mpCurrentSndSlot->WaveChunk();
// play sample on first free unreserved channel
const auto sndVol = gSound.getSoundVolume();
Mix_VolumeChunk(waveChunk, sndVol);
// play sample on given Channel
// play it exactly once through
if(Mix_PlayChannel(mId, waveChunk, 0) == -1)
{
gLogging.ftextOut("Mix_PlayChannel: %s\n", Mix_GetError());
}
}
}
/** \brief This program reads the balance information and balances the stereo sound
......
......@@ -37,7 +37,8 @@ void CSoundSlot::setupWaveForm( Uint8 *buf, Uint32 len )
{
gLogging.ftextOut("Mix_QuickLoad_WAV: %s\n", Mix_GetError());
// handle error
}
return;
}
}
void CSoundSlot::setupWaveForm( const std::vector<Uint8>& waveform )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment