0

I'm attempting to apply a low-pass filter to a sound I load and play through SoundJS.

Right now I'm attempting to do this like this:

    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");

But I'm not having much luck. Could someone point me in the right direction?

Thanks

Tarrence
  • 794
  • 1
  • 6
  • 14

1 Answers1

0

When I built the MusicVisualizer demo one of the interesting limitations I found was that all of the audio nodes had to be built using the same context to work. You can access the SoundJS context via createjs.WebAudioPlugin.context

You'll also need to connect your filter into the existing node flow if you want it to work as expected. You can see the MusicVisualizer demo on github if you want to review the source, which does this. You can also review the documentation online, which might be helpful.

Hope that helps.

OJay
  • 1,249
  • 7
  • 14
  • Awesome, thanks! I actually figured it out by looking at the source of your visualizer before you posted this but nice to have the github link too. – Tarrence Nov 14 '13 at 20:28