【发布时间】:2019-05-30 11:24:35
【问题描述】:
我正在尝试使用 sfml 录制一些声音,然后播放。我以前用我相信有 5.1 音响系统的旧耳机成功地做到了这一点。但是现在当我尝试用我的新耳机(7.1 声音)做同样的事情时。代码抛出此错误。
AL 库:(EE) SetChannelMap:无法匹配前端中心通道 (2) 在频道地图中。
我已尝试重新启动 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;
}
【问题讨论】: