- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在从 Canvas 实例化 MediaStream。我需要将来自 Three.js 的音频流中的音频连接到该流。
我已经尝试了很多东西,但最简洁的是提供的代码。是否已添加流,但听不到音频?
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]);
我想听到 Three.JS 的音频,但我听不到任何声音。我可以在游戏本身中调节音量。这会影响事情吗?我应该注意,我首先调用 canvas.captureStream(),然后执行此“轨道添加”,然后实例化记录器。
最佳答案
对于 FuTuRe 中的开发者:
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,请调用 createMediaStreamDestination 并将 GainNode(音量节点)连接到新创建的目标。然后,将轨道添加到流中。
我有几个问题:- 您连接的所有增益节点都需要位于相同的音频上下文下。- 如果你想将音频连接到流中,即使可能听不到,你也需要创建一个独立的GainNode。
当然,我说 GainNode 是因为您可能使用不同类型的 AudioNode,但我假设 95% 的人只是希望播放音频而不需要对音量进行任何更改。
关于javascript - 如何从 Three.JS AudioContext 将音频连接到 MediaStream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57358937/
我的代码在 Chrome 中运行良好,但现在我认为由于 Chrome 更新,它停止运行了。 var audioContext = new(window.audioContext || window.w
我想在我的游戏中使用麦克风(点击,游戏有音乐和音效,我使用 HTML5 音频元素),如果我添加(仅!)这一行: var audioCtx = new AudioContext (); 并在 Chrom
我正在开发一个 JavaScript 库 ( https://github.com/yvesgurcan/web-midi-player ) 以在 Web 应用程序中启用 MIDI 播放。该库依赖于
我正在开发一个 JavaScript 库 ( https://github.com/yvesgurcan/web-midi-player ) 以在 Web 应用程序中启用 MIDI 播放。该库依赖于
作为这篇文章的后续:How to rapidly play multiple copies of a soundfile in javascript我创建了一个小的演示页面来说明我的问题的核心。 我的
我以前使用过 javascript Audio(),但现在我需要在音频中添加一些混响效果,我正在使用使用 AudioContext api 的 reverb.js。我有可用的开始属性,但没有暂停属性?
我遵循一种模式使用 Webaudio 将声音附加到对象。它运行良好,但是,如果我在一个页面上生成多个项目并附加此脚本,我会收到一个 console.log,表明我已经超过了每页可用的 audioCon
使用 WebAudio API 播放直播流的正确方法是什么。 我正在尝试使用以下代码,但是我看到的只是正在下载 MP3,但没有播放;可能 MediaElementSource 需要一个文件,而不是连续
受此启发SO answer ,我有这段代码,它可以工作,但它会弹出并且听起来不太流畅。 $('.btn').each(initDraggable); function initDraggable()
我有两个一秒音频源,如下所示: var context = system.AudioContext(); var source = context.createBufferSource(); var
我知道你不能多次演奏振荡器,所以我编写了一个函数,每次都会创建一个新的振荡器: function playFrequency(f, t0, t1){ console.log(f, t0, t1
我试图在三星 Galaxy SII 4G 上的最新版本的 Chrome (34.0.1847.114) 中使用 AudioContext(),但由于某种原因 AudioContext() 不存在,we
我已经关注了这个 tutorial并提出该代码: context = new AudioContext(); play(frequency) { const o = this.context.
如果我现在需要在 HTML5 中使用音频 API,我应该使用哪一个?我看到两个可用的 API:Audio API 和 Web Audio API。 基于 this documentation from
我正在构建一个音乐播放器,我想根据当前播放的轨道添加脉动效果。 这里是我想要的一些例子: http://www.htmlfivewow.com/demos/hal/index.html http://
我正在分析一个音频文件,以便使用 channelData 来驱动我的 webapp 的另一部分(基本上是基于音频文件绘制图形)。播放的回调函数如下所示: successCallback(mediaSt
所以,我刚刚发现你可以 record sound using javascript 。太棒了! 我立即创建了一个新项目来自己做一些事情。然而,当我打开示例脚本的源代码时,我发现根本没有任何解释性注释。
我正在寻找一种使用浏览器中的 JavaScript 生成和播放 WAVE 表单的方法。该方法解释如下:http://js.do/blog/sound-waves-with-javascript/ ,非
我正在尝试使用 XMLHttpRequests 和 AudioContext 加载音频,我的代码如下所示: class AudioExample audioContext: null
var audioContext = new window.AudioContext chrome.runtime.onMessage.addListener( function(imageUrl
我是一名优秀的程序员,十分优秀!