gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 04:52:58 28 4
gpt4 key购买 nike

我正在尝试用 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 个 channel 的录制。如果我们检查方法的文档 setChannelCount() SoundRecorder 类的它最多只支持 2 个( channel )。


编辑

来自 openAL图书馆,基于(强调我的):

hexagon.ambdec

Specifies a flat-front hexagonal speaker setup for 7.1Surround output. The front left and right speakers are placed at +30and -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 speakerwill be silent for 3D sound (however it may still be used withAL_SOFT_direct_channels or ALC_EXT_DEDICATED output). A "proper" 7.1decoder may be provided in the future, but due to the nature of thespeaker configuration will have trade-offs.

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

关于c++ - 如何使用 7.1 音频系统 sfml 播放声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54029621/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com