使用 3D 声音时,我听不出前后位置的区别

I cannot hear the difference between front and behind position using 3D sound

我想制作真正的3D音效。我能听出左右的区别,但听不出前后的区别

以下是我设置侦听器的方式:

sf::Listener::setPosition(0.f, 0.f, 0.f);
sf::Listener::setDirection(0.f, 0.f, 1.f);

我是这样设置声音位置的:

sound.setPosition(0.f, 0.f, -10.f);

下一秒再移动

sound.setPosition(0.f, 0.f, 10.f);

如果我改变 X 坐标,我听到声音从左向右移动,但它不适用于 Z 坐标。

我做错了什么?

这段代码对我有用。前面声音有点怪

#include <SFML/Audio.hpp>
#include <iostream>
#include <math.h>

int main()
{
    // initialize and play our custom stream
    sf::Music stream;
    stream.openFromFile("music.ogg");

    #define MAX_R 10
    #define PI 3.141592653589793238
    float x = MAX_R, y = 0, z = MAX_R;
    stream.setPosition(x, y, z);
    stream.setVolume(100);
    stream.setMinDistance(5.f);
    stream.setAttenuation(10.f);
    stream.setLoop(true);

    stream.play();

    float angle = 0.f;

    // let it play until it is finished
    while (stream.getStatus() == sf::SoundSource::Playing) {
        sf::sleep(sf::seconds(0.1f));

        x = cos(angle * PI / 180) * MAX_R;
        z = sin(angle * PI / 180) * MAX_R;

        std::cout << x << " " << z << " ";
        if (angle < 90.f)
            std::cout << "1\n";
        else if (angle < 180.f)
            std::cout << "2\n";
        else if (angle < 270.f)
            std::cout << "3\n";
        else
            std::cout << "4\n";

        stream.setPosition(x, y, z);
        angle += 5.f;
        if (angle > 360)
            angle = 0.f;
    }

    return 0;
}

参考文献:
sf::Music Doc
Audio Spatialization with SFML
Audio Streams