【问题标题】:Sample-accurate punch-in and punch-out recording using tone.js使用tone.js 进行采样准确的切入和切出录音
【发布时间】:2020-08-29 17:13:40
【问题描述】:

使用下面的代码,我尝试使用tonejs` Recorder(MediaRecorder 的包装器)精确录制一个小节。

const userMedia = new Tone.UserMedia();
await userMedia.open();
const recorder = new Recorder();
userMedia.connect(recorder);

Tone.Transport.scheduleOnce(t => {
  console.log('starting recorder', t);
  recorder.start();
}, "4:0:0");

Tone.Transport.scheduleOnce(async t => {
  const data = await recorder.stop();
  // ... when I load the audio data into a SamplePlayer and inspect the buffer:
  //  * the length in seconds is 1.97 (I expect 2.0 for a bar when the tempo is 120 bpm)
  //  * the length in samples is 87317 (I expect 88200 for 2 secs w/ 44.1 sample rate) 

}, "5:0:0");

录制后,我将音频数据加载到SamplePlayer 并检查缓冲区:

  • 以秒为单位的长度为 1.97(当速度为 120 bpm 时,我希望小节为 2.0)
  • 样本长度为 87317(我预计 88200 持续 2 秒,采样率为 44.1)

我正在寻找有关如何准确录制一段音频(即 88200 个样本,120 bpm 和 44.1 采样率)的建议,并且录制音频的开头正好在测量范围内。

【问题讨论】:

    标签: javascript web-audio-api tone.js


    【解决方案1】:

    这是不可能的,因为Recorder 类依赖于here at mdn 描述的MediaSream Recording API。这是一个独立的 API,不具备任何样本准确性。

    您需要做的是创建自己的 AudioProcessorWorklet,将 UserMedia Stream 与它连接起来,然后从 worklet 中获取输入样本以创建 AudioBuffer。然后您可以通过参数以精确的方式控制样本的抓取(记录)和不抓取(不记录)。

    【讨论】:

      猜你喜欢
      • 2017-06-27
      • 2020-06-16
      • 1970-01-01
      • 2023-02-08
      • 2020-03-23
      • 2021-01-05
      • 1970-01-01
      • 1970-01-01
      • 2013-05-02
      相关资源
      最近更新 更多