I have a problem with doppler in that when i play any sound, it is played back at a VERY high speed/pitch.

My basic setup:

[code:3r7ktnki]errorCode = FMOD::System_Create(&system);
// try to use alsa because it autodetect does not work on linux with alsa
errorCode = system->setOutput(FMOD_OUTPUTTYPE_ALSA);
// if ALSA does not work we might be on windows, trying to autodetect
if (errorCode != FMOD_OK) {
errorCode = system->setOutput(FMOD_OUTPUTTYPE_AUTODETECT);
// if that doesn’t work either, print an error message
errorCode = system->setDriver(0);
errorCode = system->init(1000, FMOD_INIT_NORMAL, 0);
// set factor to 100 for 1 meter, doppler to 1
system->set3DSettings(1.0f, 100.0f, 1.0f);[/code:3r7ktnki]

This is the code for my listener position, so velocity is always zero for now

[code:3r7ktnki]FMOD_VECTOR position = toFMOD(attr->player->camera->getPosition());
FMOD_VECTOR up = toFMOD(attr->player->camera->getUpVector());
forw = attr->player->camera->getTarget() – attr->player->camera->getPosition();
FMOD_VECTOR forward = toFMOD(forw);
FMOD_VECTOR velocity;
velocity.x = 0;
velocity.y = 0;
velocity.z = 0;
sound->setPosition(&position, &velocity, &forward, &up);[/code:3r7ktnki]

The function above goes like this:

[code:3r7ktnki]void CSound::setPosition(FMOD_VECTOR * position, FMOD_VECTOR * velocity , FMOD_VECTOR * forward, FMOD_VECTOR * up) {
system->set3DListenerAttributes(0, position, velocity, forward, up);

Then there is the channel code:
FMOD::Channel * channel;
system->playSound(FMOD_CHANNEL_FREE, pos->sound, true, &channel);
channel->set3DAttributes(&pos, &vel);[/code:3r7ktnki]

where &pos and &vel are always zero for now.

As long as i use:


everything is ok, but i got no doppler effect when moving. When I change it to 1, everything is sounding at a very high speed.

Perhaps there is something obvious I missed?

thanks for reading,


  • You must to post comments

as usual, the problem was not at all with the code i posted, but with some unsuspicious but uninitialized variable used in the velocity calculation. Which made the camera move at lightspeed, even when it was standing still :-)

Sorry for the trouble…

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.