mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-28 12:40:06 +00:00
Tested and applied Chris' sound patch.
This commit is contained in:
parent
6a12ce313e
commit
004541f5cf
@ -110,20 +110,21 @@ namespace MWSound
|
|||||||
cameraTracker.unfollowCamera();
|
cameraTracker.unfollowCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toMp3(const std::string &str)
|
static std::string toMp3(std::string str)
|
||||||
{
|
{
|
||||||
std::string wav = str;
|
std::string::size_type i = str.rfind('.');
|
||||||
int i = str.size()-3;
|
if(str.find('/', i) == std::string::npos &&
|
||||||
wav[i++] = 'm';
|
str.find('\\', i) == std::string::npos)
|
||||||
wav[i++] = 'p';
|
str = str.substr(0, i) + ".mp3";
|
||||||
wav[i++] = '3';
|
else
|
||||||
return wav;
|
str += ".mp3";
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasFile(const std::string &str)
|
bool hasFile(const std::string &str)
|
||||||
{
|
{
|
||||||
if(files.has(str)) return true;
|
if(files.has(str)) return true;
|
||||||
// Not found? Try exchanging .wav with .mp3
|
// Not found? Try with .mp3
|
||||||
return files.has(toMp3(str));
|
return files.has(toMp3(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,10 +154,24 @@ namespace MWSound
|
|||||||
const ESM::Sound *snd = store.sounds.search(soundId);
|
const ESM::Sound *snd = store.sounds.search(soundId);
|
||||||
if(snd == NULL) return "";
|
if(snd == NULL) return "";
|
||||||
|
|
||||||
volume *= snd->data.volume / 255.0f;
|
if(snd->data.volume == 0)
|
||||||
// These factors are not very fine tuned.
|
volume = 0.0f;
|
||||||
min = snd->data.minRange * 7.0f;
|
else
|
||||||
max = snd->data.maxRange * 2000.0f;
|
volume *= pow(10.0, (snd->data.volume/255.0f*3348.0 - 3348.0) / 2000.0);
|
||||||
|
|
||||||
|
if(snd->data.minRange == 0 && snd->data.maxRange == 0)
|
||||||
|
{
|
||||||
|
min = 100.0f;
|
||||||
|
max = 2000.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
min = snd->data.minRange * 20.0f;
|
||||||
|
max = snd->data.maxRange * 50.0f;
|
||||||
|
min = std::max(min, 1.0f);
|
||||||
|
max = std::max(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
return convertPath(snd->sound);
|
return convertPath(snd->sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +324,7 @@ namespace MWSound
|
|||||||
// The range values are not tested
|
// The range values are not tested
|
||||||
if(!mData) return;
|
if(!mData) return;
|
||||||
if(mData->hasFile(filename))
|
if(mData->hasFile(filename))
|
||||||
mData->add(mData->convertPath(filename), ptr, "_say_sound", 1, 1, 100, 10000, false);
|
mData->add(mData->convertPath(filename), ptr, "_say_sound", 1, 1, 100, 20000, false);
|
||||||
else
|
else
|
||||||
cout << "Sound file " << filename << " not found, skipping.\n";
|
cout << "Sound file " << filename << " not found, skipping.\n";
|
||||||
}
|
}
|
||||||
@ -342,10 +357,11 @@ namespace MWSound
|
|||||||
const std::string &file = mData->lookup(soundId, volume, min, max);
|
const std::string &file = mData->lookup(soundId, volume, min, max);
|
||||||
if(file != "")
|
if(file != "")
|
||||||
{
|
{
|
||||||
SoundPtr snd = mData->mgr->play(file);
|
SoundPtr snd = mData->mgr->load(file);
|
||||||
snd->setVolume(volume);
|
snd->setVolume(volume);
|
||||||
snd->setRange(min,max);
|
snd->setRange(min,max);
|
||||||
snd->setPitch(pitch);
|
snd->setPitch(pitch);
|
||||||
|
snd->play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 7a22068da611235190fa7343ca3f8c1d1944a68c
|
Subproject commit 7345f2307f3ce6682a4044b98a811fac2cb7c4f0
|
Loading…
x
Reference in New Issue
Block a user