使用下面的代码,我尝试使用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");
录制后,我将音频数据加载到 aSamplePlayer
并检查缓冲区:
- 以秒为单位的长度为 1.97(当速度为 120 bpm 时,我预计小节为 2.0)
- 样本长度为 87317(我预计 88200 持续 2 秒,采样率为 44.1)
我正在寻找有关如何准确录制一个音频小节的建议(即 88200 个样本,带 120 bpm 和 44.1 采样率),录制音频的开头正好在测量中。