The ScriptProcessorNode is deprecated. Use AudioWorkletNode instead

Viewed 3214

There is a sound recorder and a recorded sound player on the site. It's fine with Firefox, but I get the following warning in Chronium-based browsers.

[Deprecation] The ScriptProcessorNode is deprecated. Use AudioWorkletNode instead. (https://developers.google.com/web/updates/2017/12/audio-worklet)

this.config = {
                        bufferLen: 4096,
                        numChannels: 2,
                        mimeType: 'audio/ogg'
                    };
                    this.recording = false;
                    this.callbacks = {
                        getBuffer: [],
                        exportWAV: []
                    };
                    Object.assign(this.config, cfg);
                    this.context = source.context;
                    this.node = (this.context.createScriptProcessor || this.context.createJavaScriptNode).call(this.context, this.config.bufferLen, this.config.numChannels, this.config.numChannels);
                    this.node.onaudioprocess = function (e) {
                        if (!_this.recording) return;
                        var buffer = [];
                        for (var channel = 0; channel < _this.config.numChannels; channel++) {
                            buffer.push(e.inputBuffer.getChannelData(channel));
                        }
                        _this.worker.postMessage({
                            command: 'record',
                            buffer: buffer
                        });
                    };

Full Code on PasteBin

enter image description here

How can I make this change?

1 Answers
Related