使扬声器中的麦克风静音,但仍然可以使用Web Audio Api分析(createAnalyser)吗? [英] Mute microphone in speakers but still be able to analyze (createAnalyser) with Web Audio Api?

查看:250
本文介绍了使扬声器中的麦克风静音,但仍然可以使用Web Audio Api分析(createAnalyser)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个Analyzer节点以从麦克风获取信号,并能够使用接收到的输入来创建图形.但是我不想让扬声器仍然接收到麦克风信号.

Im trying to create an Analyser node to get the signal from a microphone, and be able to create a graphic with the received input. But I dont want to the speakers to still recive the microphone signal.

源(麦克风)->分析器->目标(?)

Source (microphone) -> Analyser -> Destination(?)

目的地始终是说话者...我可以将目的地放在空白处或类似地方,并且仍然能够分析麦克风吗?

The destination is always the speakers... Can I put the destination to a void or similar, and be able to still analyze the microphone?

我尝试使用Volumne(增益节点),但最终影响了分析仪.

I tried to play with the Volumne (gain node) but that affects the analyser in the end.

总之:我需要能够分析来自麦克风的输入,但要使扬声器上的信号静音.

In summary: I need to be able to analyze an input from the microphone but mute that signal on the speakers.

这是我在做什么.

analyser = context.createAnalyser();
analyser.smoothingTimeConstant = 0.4;
analyser.fftSize = 64;

microphone.connect(analyser)
analyser.connect(context.destination);

这工作正常...但是我正在扬声器上听到声音. 如果我问例如:

This is working fine... but Im getting the sound on the speakers. If I ask for example:

var data = new Uint8Array(analyzer.frequencyBinCount);
analyzer.getByteFrequencyData(data)

然后数据将包含来自麦克风的响应.

Then data will contain the reponse from microphone.

但是如果我这样增加收益

But if I add gain after like this

volume.gain.value = 0; 
microphone.connect(analyser)
analyser.connect(volume);
volume.connect(context.destination);

或者我没有连接到 context.destination ,那么数据数组将全部为0(不是来自麦克风的响应)

or I do not make the connect to context.destination, then the data array will be all 0 (not reponse from microphone)

推荐答案

实际上,您甚至不需要连接分析器.它应该在不连接到目的地的情况下进行处理.

Actually, you don't even need to connect the analyser. It should process without being connected to the destination.

这篇关于使扬声器中的麦克风静音,但仍然可以使用Web Audio Api分析(createAnalyser)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆