【问题标题】:AudioBuffer not defined while using Tone.js inside of Node.js在 Node.js 中使用 Tone.js 时未定义 AudioBuffer
【发布时间】:2021-08-04 13:12:01
【问题描述】:

这是我当前的代码。我想在不使用 Web 浏览器的情况下使用 Node.js 中的 Tone.js 库。到目前为止,我知道AudioBuffer 是浏览器的一项功能,但我怎样才能让这段代码在 Node.js 中工作?

const Tone = require("Tone");

//create a synth and connect it to the main output (your speakers)
Tone = new Tone.Synth().toDestination();

//play a middle 'C' for the duration of an 8th note
Tone.triggerAttackRelease("C4", "8n");

这是我得到的错误:

ReferenceError: AudioBuffer is not defined

然后它链接到 node_modules 文件夹中的 Tone.js 文件。

【问题讨论】:

    标签: javascript node.js tone.js


    【解决方案1】:

    Tone.js 使用网络音频。您正在尝试在节点上下文中运行它。我正在为同样的问题苦苦挣扎:我已经有一个在浏览器中运行的离线进程,但现在我正在尝试使用云功能使其成为服务器端。现在我正在考虑使用这个:https://github.com/audiojs/web-audio-api

    我的想法是将此节点音频上下文传递给音调,但我不确定它有多简单。

    如果我取得了一些成功,我会及时通知你。 问候。 dx

    【讨论】:

    • 这个运气好吗? @aboiledtiger
    猜你喜欢
    • 1970-01-01
    • 2021-08-01
    • 1970-01-01
    • 2021-04-14
    • 2015-05-25
    • 2020-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多