我想用麦克风播放录制的音频。
将其记录为32位阵列后
let left = e.inputBuffer.getChannelData(0);
let tempLeftChannel = this.state.leftChannel;
tempLeftChannel.push(new Float32Array(left));
this.setState({ leftChannel: tempLeftChannel });
现在在leftChannel数组中,我有大量的音频数据。现在,我想在浏览器中播放它们。我怎样才能做到这一点?
你从你的片段中留下了很多东西,但是下面的内容可能会让你知道一种方法来播放你拥有的浮点数组。让context
成为你可能拥有的AudioContext
。
let buffer = new AudioBuffer({length: leftChannel.length,
sampleRate: context.sampleRate});
buffer.copyToChannel(leftChannel, 0);
let source = new AudioBufferSourceNode(context, {buffer: buffer});
source.connect(context.destination);
source.start();