[SOLVED] Trouble with getting 3d effect to work

jjonj

14-09-2014 22:03:19

Hey there everyone!

I've been working with OgreOggSound for a while now and I'm quite happy with it, I do however have some issues with getting 3d sound to work.
My 3d sounds don't change in volume or speaker position when moving around, and I've tried to debug the issue quite a bit to no avail.

From my debugging I've confirmed that I have both sound and listener attached to scenenodes and that both sound and listener have their positions updated correctly.

Here is codesnippets that I find relevant:

void
setupSoundManager() {
static const std::string DEVICE_NAME = "";
static const unsigned int MAX_SOURCES = 100;
static const unsigned int QUEUE_LIST_SIZE = 100;
auto& soundManager = OgreOggSound::OgreOggSoundManager::getSingleton();
soundManager.init(
DEVICE_NAME,
MAX_SOURCES,
QUEUE_LIST_SIZE
);
soundManager.setDistanceModel(AL_LINEAR_DISTANCE);
}


-- lua, note that I have confirmed that these properties are being set to the correct values in C++
s1 = soundComponent:addSound("microbe-movement-2", "soundeffects/microbe-movement-2.ogg")
s1.properties.rolloffFactor = 0.5
s1.properties.referenceDistance = 2.0
s1.properties.maxDistance = 100


OgreOggSound::OgreOggISound* ogreSound = soundManager.createSound(
soundName.str(),
sound->filename(),
STREAM,
sound->m_properties.loop,
PREBUFFER,
gameState->sceneManager()
);
if (ogreSound) {
sound->m_sound = ogreSound;
// ogreSound->disable3D(ambient);
if (ambient) {
std::cout << "disable 3d for sound " << sound->name() << std::endl;
ogreSound->disable3D(true);
}
if (autoLoop) {
// We want to manage looping ourselves
sound->m_properties.loop = false;
ogreSound->loop(false);
}
m_sounds[entityId].emplace(sound->name(), ogreSound);
if (not ambient){
sceneNodeComponent->m_sceneNode->attachObject(ogreSound);
}
sound->m_properties.touch();
}


OgreOggSound::OgreOggISound* ogreSound = sound->m_sound;
ogreSound->loop(properties.loop and not soundSourceComponent->m_autoLoop);
ogreSound->setVolume(properties.volume * soundSourceComponent->m_volumeMultiplier);
std::cout << "sound: " << sound->name() << " setting props to: maxdist " << properties.maxDistance << ", rolloff " << properties.rolloffFactor << ", referencedist " << properties.referenceDistance << std::endl;
ogreSound->setMaxDistance(properties.maxDistance);
ogreSound->setRolloffFactor(properties.rolloffFactor);
ogreSound->setReferenceDistance(properties.referenceDistance);
ogreSound->setPriority(properties.priority);

Also note that disable3d is not ever called for the sounds that I need to have as 3d.


Here's my ogre log (no apparent issues): http://pastebin.com/XsLsvC5N

Here's the only two files (and their headers) that work with OggOgreSound directly (uses artemis entity component system framework so may be a bit confusing ):
http://pastebin.com/ZqmtnYVL
http://pastebin.com/degAcG8h
http://pastebin.com/e1iUWKM2
http://pastebin.com/p3yMUw05

The absolute full sourcecode can be found at https://github.com/Revolutionary-Games/ ... nd-effects

If anyone can see what I'm doing wrong to not have 3d effects work for the appropriate sounds, I'd greatly appreciate any advice on what could be the problem or what I could try to debug! Thanks :)

EDIT: I will also note that I have experimented with rolloff, reference distance and maximum distance to no apparent effect.

Yevgeny

18-09-2014 09:31:17

Hello,

are your sound files in mono mode? As mentioned in documentation, stereo sounds can't be used for spatial effects in OpenAL, which underlies OgreOggSound.

jjonj

18-09-2014 22:27:03

Ah, I'll check that out, thanks!

jjonj

20-09-2014 13:33:02

That was my issue! Thank you very much!