【问题标题】:Webaudio :: Play Recorded AudioWebaudio :: 播放录制的音频
【发布时间】:2019-02-09 15:10:24
【问题描述】:

我想用麦克风播放录制的音频。

将其记录为 32 位数组后

    let left = e.inputBuffer.getChannelData(0);
    let tempLeftChannel = this.state.leftChannel;
    tempLeftChannel.push(new Float32Array(left));
    this.setState({ leftChannel: tempLeftChannel });

现在在 leftChannel 数组中,我有一大块音频数据。现在,我想在浏览器中播放它们。我该怎么做?

【问题讨论】:

    标签: web-audio-api


    【解决方案1】:

    你从你的 sn-p 中留下了很多东西,但也许下面的内容会让你知道一种方法来播放你拥有的浮点数组。让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();
    

    【讨论】:

      猜你喜欢
      • 2016-09-24
      • 2013-06-19
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-04
      • 1970-01-01
      相关资源
      最近更新 更多