将过滤器应用于音频上下文



我正在尝试将低通滤波器应用于我通过 SoundJS 加载和播放的声音。

现在我正在尝试这样做:

    var audio = createjs.Sound.activePlugin;
    var source = audio.context.createBufferSource();
    // Create the filter
    var filter = audio.context.createBiquadFilter();
    // Create the audio graph.
    source.connect(filter);
    filter.connect(audio.context.destination);
    // Create and specify parameters for the low-pass filter.
    filter.type = 0; // Low-pass filter. See BiquadFilterNode docs
    filter.frequency.value = 440; // Set cutoff to 440 HZ
    // Playback the sound.
    createjs.Sound.play("Song");

但我运气不好。有人可以指出我正确的方向吗?

谢谢

当我构建 MusicVisualizer 演示时,我发现的一个有趣的限制是,所有音频节点都必须使用相同的上下文才能工作。 您可以通过createjs.WebAudioPlugin.context访问 SoundJS 上下文

如果您希望筛选器按

预期工作,则还需要将筛选器连接到现有节点流中。 如果你想查看源代码,你可以在github上看到MusicVisualizer演示,它就是这样做的。 您还可以在线查看文档,这可能会有所帮助。

希望有帮助。

最新更新