如何将音频连接到来自TRIST.JS AudioContext的MediaStream



我正在从画布上插入媒介。我需要将音频连接到来自三个音频流的音频流。

我尝试了很多事情,但最简洁的是提供的代码。流是添加的,但是音频没有听到吗?

const context: AudioContext = ThreeAudioContext.getContext();
const destination = context.createMediaStreamDestination();
const source = context.createMediaStreamSource(destination.stream);
source.connect(destination);
stream.addTrack(destination.stream.getAudioTracks()[0]);

我也尝试过查看音频是否已连接,但我仍然听不到任何声音。

const context: AudioContext = ThreeAudioContext.getContext();
const destination = context.createMediaStreamDestination();
const source = context.createMediaStreamSource(destination.stream);
const gainNode = context.createGain();
gainNode.gain.value = 1;
source.connect(gainNode);
gainNode.connect(destination);
stream.addTrack(destination.stream.getAudioTracks()[0]);

我想听到来自三分的音频,但我什么都没听到。我的游戏本身可以调节音量。那会影响事物吗?我应该注意,我首先调用Canvas.capturestream((,然后执行此"曲目添加"然后实例化录音机。

将来开发人员:

const context: AudioContext = ThreeAudioContext.getContext();
const destination = context.createMediaStreamDestination();
this.audioListener.getInput().connect(destination);
this.backgroundGainNode.connect(destination);
stream.addTrack(destination.stream.getAudioTracks()[0]);

简而言之,要将音频连接到Mediarecorder,请调用createMediasTreamDestatination,然后将增益节(卷节点(连接到新创建的目标。然后,将曲目添加到流中。

我遇到的几个打ic: - 您连接的所有增益节点都需要在相同的音频上下文下进行。 - 如果您想将音频连接到流,即使可能无法听到音频,您也需要创建一个独立的增益节点。

当然,我说的是有了了解您可能正在使用其他类型的Audionode的收益表,但是我认为95%的人只希望音频播放,而没有任何更改。

最新更新