如何使用 7.1 音频系统 sfml 播放声音?

How to play sound with 7.1 audio system sfml?

我正在尝试用 sfml 录制一些声音然后播放。我以前用我相信有 5.1 音响系统的旧耳机成功地做到了这一点。但是现在当我尝试用我的新耳机(7.1 声音)做同样的事情时。代码抛出此错误。

AL lib: (EE) SetChannelMap: Failed to match front-center channel (2) in channel map.

我已尝试重新启动 visual studio。重新启动我的电脑。在 visual studio.

重置缓存
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <thread>
#include <chrono>

int main()
{
    sf::ContextSettings settings;
    settings.antialiasingLevel = 8;
    sf::RenderWindow window;
    window.create(sf::VideoMode(800, 500), "Audio check", sf::Style::Close | sf::Style::Resize);
    if (!sf::SoundBufferRecorder::isAvailable())
    {
        // error: audio capture is not available on this system
        std::cout << "Something went wrong" << std::endl;
    }

    // create the recorder
    sf::SoundBufferRecorder recorder;

    recorder.start(44100);
    //record the audio for 5 sec
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    recorder.stop();

    //get the buffer from the recorder and play it back
    const sf::SoundBuffer& buffer = recorder.getBuffer();
    sf::Sound sound(buffer);
    sound.play();

    sf::Event event;
    while (window.isOpen()) {

        while (window.pollEvent(event)) {
            switch (event.type) {
            case sf::Event::Closed:
                window.close();
                break;
            }
        }
        window.clear(sf::Color::Blue);
        window.display();
    }

    return EXIT_SUCCESS;
}

实际上SFML不支持多于2个频道的录音。如果我们查看 class SoundRecorder 方法 setChannelCount() 的文档,它最多只支持 2 个(通道)。


编辑

来自 openAL library, which 基于(强调我的):

hexagon.ambdec

Specifies a flat-front hexagonal speaker setup for 7.1 Surround output. The front left and right speakers are placed at +30 and -30 degrees, the side speakers are placed at +90 and -90 degrees, and the back speakers are placed at +150 and -150 degrees. Although this is for 7.1 output, no front-center speaker is defined for the decoder, meaning that speaker will be silent for 3D sound (however it may still be used with AL_SOFT_direct_channels or ALC_EXT_DEDICATED output). A "proper" 7.1 decoder may be provided in the future, but due to the nature of the speaker configuration will have trade-offs.

该库似乎与实际的 7.1 解码器无关。