Dan Zen
Dan Zen

Reputation: 555

Passing an AudioBuffer to AudioContext Analyser in CreateJS

I have made an audioCtx in JavaScript using the AudioContext() class. I have an analyser made with audioCtx.createAnalyser(). If my audio is an audio tag and I make a source with audioCtx.createMediaElementSource(audio) then pass that to the analyser: source.connect(analyser); this works - I receive data. I can also connect a mic using audioCtx.createMediaStreamSource(stream); etc.

BUT, if my source is a CreateJS AbstractSoundInstance object (called input) which has a playbackResource property (the sound is playing) that returns an AudioBuffer object:

AudioBuffer { sampleRate: 44100, length: 5961072, duration: 135.1717006802721, numberOfChannels: 2 }

I can't seem to connect this. I have tried

var source = audioCtx.createBufferSource(input.playbackResource);

and then tried connecting the destination with analyser.connect(audioCtx.destination); but I cannot get any data. The only hook I seem to have into the CreateJS sound is the playbackResource - the SoundJS docs say: "For example, WebAudioPlugin will set an array buffer."

Any recommendations on how to pass that AudioBuffer to the Analyser (Lanny? Grant?) Thanks!

Upvotes: 2

Views: 267

Answers (0)

Related Questions