【问题标题】:Web Audio API: How do I play a mono source in only left or right channel?Web Audio API:如何仅在左声道或右声道中播放单声道源?
【发布时间】:2015-08-14 00:50:48
【问题描述】:

是否有一种(简单的)方法来获取单声道输入并仅在左声道或右声道中播放?我想我可以通过 ScriptProcessing 节点来做到这一点,但是如果有一个节点可以处理这种情况,我真的很想知道。 API 有一个关于混合的部分,但我没有看到任何关于如何以这种方式自己操作通道的代码。

注意,我已经尝试过 panner 节点,但它似乎并没有真正切断右声道的左声道,我不希望任何声音从一个声道流到另一个声道。

【问题讨论】:

    标签: web-audio-api


    【解决方案1】:

    您确实想使用 ChannelSplitter,尽管在通道未连接时会出现错误。看到这个问题:Play an Oscillation In a Single Channel

    【讨论】:

      【解决方案2】:

      看一下拆分器节点:https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#ChannelSplitterNode-section

      ChannelSplitterNode 的一个应用是进行“矩阵混合”,需要对每个通道进行单独的增益控制。

      (我还没试过,请告诉我:)

      【讨论】:

        【解决方案3】:

        您可以尝试使用CreatePanner() 然后setPosition() 到所需的频道。不要忘记将您之前的节点连接到 panner 节点,并将 panner 连接到 context.destination

        例如:

        //Lets create a simple oscilator just to have some audio in our context
        var oscillator = context.createOscillator();
        
        //Now lets create the panner node
        var pannerNode = context.createPanner();
        
        //Connecting the nodes
        oscillator.connect(pannerNode); //Connecting the oscillator output to the panner input
        pannerNode.connect(context.destination); //Connecting the panner output to our sound output
        
        //Setting the position of the sound
        pannerNode.setPosition(-1, 0, 0);//If you want it to play on the left channel
        pannerNode.setPosition(1, 0, 0);//If you want it to play on the right channel
        
        //Playing the sound
        oscillator.noteOn(0);
        

        这是你需要的吗?

        【讨论】:

        • 有人建议和编辑。你能复习一下吗,它看起来至少漏掉了一个错字。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多