1
0
forked from 0ad/0ad

volume roilloff returned to standard with bug fixed. Added hints to help stereo playback

This was SVN commit r12864.
This commit is contained in:
stwf 2012-11-18 22:39:20 +00:00
parent 355bdfb748
commit a23d245405
8 changed files with 28 additions and 48 deletions

View File

@ -295,7 +295,9 @@ Status CSoundManager::AlcInit()
m_Device = alcOpenDevice(NULL);
if(m_Device)
{
m_Context = alcCreateContext(m_Device, 0); // no attrlist needed
ALCint attribs[] = {ALC_STEREO_SOURCES, 16, 0};
m_Context = alcCreateContext(m_Device, &attribs[0]);
if(m_Context)
alcMakeContextCurrent(m_Context);
}

View File

@ -37,8 +37,7 @@ CSoundData::~CSoundData()
{
if (m_ALBuffer != 0)
alDeleteBuffers(1, &m_ALBuffer);
if ( m_FileName )
delete m_FileName;
delete m_FileName;
}
void CSoundData::InitProperties()
@ -120,17 +119,16 @@ ALsizei CSoundData::GetBufferCount()
return 1;
}
std::wstring* CSoundData::GetFileName()
CStrW* CSoundData::GetFileName()
{
return m_FileName;
}
void CSoundData::SetFileName(const Path& aName)
{
if ( m_FileName )
delete m_FileName;
delete m_FileName;
m_FileName = new std::wstring( aName.string() );
m_FileName = new CStrW( aName.string() );
}
CSoundData* CSoundData::IncrementCount()

View File

@ -53,7 +53,7 @@ public:
virtual ALuint GetBuffer();
virtual ALsizei GetBufferCount();
virtual std::wstring* GetFileName();
virtual CStrW* GetFileName();
virtual void SetFileName(const Path& aName);
virtual ALuint* GetBufferPtr();
@ -63,7 +63,7 @@ protected:
ALuint m_ALBuffer;
int m_RetentionCount;
std::wstring* m_FileName;
CStrW* m_FileName;
};

View File

@ -46,8 +46,6 @@ CSoundBase::~CSoundBase()
CSoundData::ReleaseSoundData(m_SoundData);
m_SoundData = 0;
}
if (m_Name)
delete m_Name;
}
void CSoundBase::ResetVars()
@ -62,7 +60,6 @@ void CSoundBase::ResetVars()
m_EndVolume = 0;
ResetFade();
m_Name = new std::string("sound name");
}
void CSoundBase::ResetFade()
@ -89,6 +86,10 @@ void CSoundBase::SetRollOff(ALfloat rolls)
{
if ( m_ALSource )
{
alSourcef(m_ALSource, AL_REFERENCE_DISTANCE, 70.0f);
AL_CHECK
alSourcef(m_ALSource, AL_MAX_DISTANCE, 200.0);
AL_CHECK
alSourcef(m_ALSource, AL_ROLLOFF_FACTOR, rolls);
AL_CHECK
}
@ -148,13 +149,6 @@ bool CSoundBase::InitOpenAL()
AL_CHECK
alSourcei(m_ALSource,AL_LOOPING,AL_FALSE);
AL_CHECK
alSourcef(m_ALSource, AL_REFERENCE_DISTANCE, 70.0f);
AL_CHECK
alSourcef(m_ALSource, AL_MAX_DISTANCE, 145.0);
AL_CHECK
alSourcef(m_ALSource, AL_ROLLOFF_FACTOR, 1.0);
AL_CHECK
return true;
}
else
@ -304,24 +298,12 @@ void CSoundBase::Stop()
}
}
const char* CSoundBase::Name()
CStrW* CSoundBase::GetName()
{
return m_Name->c_str();
}
if ( m_SoundData )
return m_SoundData->GetFileName();
std::string CSoundBase::GetName()
{
return std::string(m_Name->c_str());
}
void CSoundBase::SetNameFromPath(char* fileLoc)
{
std::string anst(fileLoc);
size_t pos = anst.find_last_of("/");
if(pos != std::wstring::npos)
m_Name->assign(anst.begin() + pos + 1, anst.end());
else
m_Name->assign(anst.begin(), anst.end());
return NULL;
}
#endif // CONFIG2_AUDIO

View File

@ -36,7 +36,6 @@ protected:
ALuint m_ALSource;
CSoundData* m_SoundData;
std::string* m_Name;
bool m_LastPlay;
bool m_Looping;
bool m_ShouldBePlaying;
@ -73,8 +72,7 @@ public:
void PlayAsMusic();
void PlayAsAmbient();
const char* Name();
std::string GetName();
CStrW* GetName();
virtual bool GetLooping();
virtual void SetLooping(bool loops);
@ -84,7 +82,7 @@ public:
protected:
void SetNameFromPath(char* fileLoc);
void SetNameFromPath(VfsPath& itemPath);
void ResetFade();
bool HandleFade();

View File

@ -37,7 +37,7 @@ public:
virtual bool IsPlaying() = 0;
virtual std::string GetName() = 0;
virtual CStrW* GetName() = 0;
virtual bool IdleTask() = 0;
virtual void Play() = 0;

View File

@ -189,7 +189,7 @@ void JSound::ScriptingInit()
CStr JSound::ToString(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
{
#if CONFIG2_AUDIO
return "[object Sound: " + (m_SndItem ? m_SndItem->GetName() : "(null)") + "]";
return "[object Sound: " + (m_SndItem ? m_SndItem->GetName()->ToUTF8() : "(null)") + "]";
#else // !CONFIG2_AUDIO
return "[object Sound: audio disabled]";
#endif // !CONFIG2_AUDIO

View File

@ -130,7 +130,7 @@ float CSoundGroup::RadiansOffCenter(const CVector3D& position, bool& onScreen, f
else {
if ((x < 0) || (x > screenWidth))
{
itemRollOff = 5.0;
itemRollOff = 2.0;
}
float pixPerRadian = audioWidth / (radianCap * 2);
answer = (x - (screenWidth/2)) / pixPerRadian;
@ -147,7 +147,7 @@ float CSoundGroup::RadiansOffCenter(const CVector3D& position, bool& onScreen, f
else {
if ((y < 0) || (y > screenHeight))
{
itemRollOff = 5.0;
itemRollOff = 2.0;
}
}
@ -162,7 +162,7 @@ void CSoundGroup::UploadPropertiesAndPlay(int theIndex, const CVector3D& positio
#if CONFIG2_AUDIO
if ( g_SoundManager ) {
bool isOnscreen;
ALfloat initialRolllOff = 1.0f;
ALfloat initialRolllOff = 0.1f;
ALfloat itemRollOff = initialRolllOff;
float offSet = RadiansOffCenter(position, isOnscreen, itemRollOff);
@ -178,11 +178,11 @@ void CSoundGroup::UploadPropertiesAndPlay(int theIndex, const CVector3D& positio
if (!TestFlag(eOmnipresent))
{
hSound->SetLocation(CVector3D((sndDist * sin(offSet)), 0, - sndDist * cos(offSet)));
if (TestFlag(eDistanceless))
hSound->SetRollOff(initialRolllOff);
else
hSound->SetRollOff(itemRollOff);
itemRollOff = 0;
hSound->SetLocation(CVector3D((sndDist * sin(offSet)), 0, - sndDist * cos(offSet)));
hSound->SetRollOff(itemRollOff);
}
if (TestFlag(eRandPitch))