connectToAnalyser not available on audioEngine in TS

Why is connectToAnalyser not available from BABYLON.Engine.audioEngine?

It works in Playground, but on a local machine in Visual Studio code, the method does not show in auto-completion. The code is like this:

import * as BABYLON from 'babylonjs';

class Music {
    private _music: BABYLON.Sound
    private _analyser: BABYLON.Analyser

    constructor(scene: BABYLON.Scene) {
        this._music = new BABYLON.Sound(
            scene, null, { streaming: true, autoplay: true })   

        this._analyser = new BABYLON.Analyser(scene)
        this._analyser.FFT_SIZE = 32
        this._analyser.SMOOTHING = 0.9

    update() {
        let fft = this._analyser.getByteFrequencyData()


and the compiler returned errors:

ERROR in D:\myBabylon\Eight\src\my-scene.ts
[tsl] ERROR in D:\myBabylon\Eight\src\my-scene.ts(14,36)
      TS2339: Property 'connectToAnalyser' does not exist on type 'IAudioEngine'.

Any help is greatly appreciated!

Hey @icezee, welcome to the Babylon family. Great to have you here.

Have you seen this page on how to use the analyzer?

Is it just a problem of it not working locally?

I did go through this document, and I also glanced through the source code audioEngine.ts on github. Playground example works fine, the problem only happens locally.

Thank you very much @PirateJC

Hmm…I think this one will likely require some of our bigger guns to help figure out. Pinging @Evgeni_Popov and @sebavan to help.

I just push my code to github.

I appreciate your help @PirateJC

You should try to use our latest preview, this has been introduced for our next 4.2 release if I remember well.


That did it! @sebavan @PirateJC

I write it down here, in case it is helpful for somebody else who needs to switch to the latest preview.
npm uninstall babylonjs -D
npm install babylonjs@preview -D