Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The ScriptProcessorNode is deprecated. Use AudioWorkletNode instead

Tags:

audio

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

The ScriptProcessorNode has been "deprecated" for years, but it isn't going anywhere anytime soon.

However, you don't need it anyway if you want a Vorbis or Opus audio recording in Ogg. Use the MediaRecorder API instead. https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder

like image 157
Brad Avatar answered Oct 27 '25 02:10

Brad