8 examples of 'decodeaudiodata' in JavaScript

Every line of 'decodeaudiodata' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
9export function decodeAudioData(buffer) {
10 return audioContext.decodeAudioData(buffer);
11}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

162private _decodeAudio() {
163
164 var _this: any = this;
165
166 this.game.audio.context.decodeAudioData(this.data.raw, function (buffer) {
167 if (buffer) {
168 _this.data.buffer = buffer;
169 _this.data.decoded = true;
170 _this.loadSuccess();
171 }
172 }, function (error) {
173
174 Kiwi.Log.error('Kiwi.Files.AudioFile: Error decoding audio data.', '#loading', '#decoding');
175 _this.loadError(error);
176
177 });
178
179}
26decodeAudioData(uint8) {
27 const {
28 options: { channel },
29 duration,
30 } = this.wf;
31 this.audioCtx
32 .decodeAudioData(uint8.buffer)
33 .then(audiobuffer => {
34 this.audiobuffer = audiobuffer;
35 this.wf.emit('audiobuffer', this.audiobuffer);
36 this.wf.emit('decodeing', this.audiobuffer.duration / duration);
37 this.channelData = audiobuffer.getChannelData(channel);
38 this.wf.emit('channelData', this.channelData);
39 })
40 .catch(error => {
41 errorHandle(false, `It seems that the AudioContext decoding get wrong: ${error.message.trim()}`);
42 });
43}
32decodeAudio (audioTrack) {
33 let {samples} = audioTrack;
34 let data = samples;
35 audioTrack.samples = [];
36 this.setAudioData(data);
37}
38setAudioData (data) {
39 for (let i = 0; i < data.length; i++) {
40 data[i].pts = (data[i].pts === undefined) ? data[i].dts : data[i].pts;
41 this._preDecode.push(data[i]);
42 }
43 if (this._preDecode.length > 0) {
44 if (this._lastpts === undefined) {
45 this._lastpts = this._preDecode[0].pts;
46 }
47 if ((this._preDecode[this._preDecode.length - 1].pts - this._lastpts) / 1000 > this.preloadTime) {
48 this.decodeAAC();
49 }
50 }
51}
256decode(arrayBuffer, callback) {
257 this._offlineCtx.decodeAudioData(
258 arrayBuffer,
259 (buffer) => {
260 callback(null, buffer);
261 },
262 () => {
263 callback(new Error("Unable to decode file"));
264 }
265 );
266}
108function onFailure() {
109 // console.error(new Error("Decoding the audio buffer failed"));
110},
31function onDecodeData (buffer) {
32
33 // Kill any existing audio
34 if (sourceNode) {
35 if (sourceNode.playbackState === sourceNode.PLAYING_STATE)
36 sourceNode.stop();
37
38 sourceNode = null;
39 }
40
41 // Make a new source
42 if (!sourceNode) {
43
44 sourceNode = audioContext.createBufferSource();
45 sourceNode.loop = false;
46
47 sourceNode.connect(gainNode);
48 gainNode.connect(analyser);
49 analyser.connect(audioContext.destination);
50 }
51
52 // Set it up and play it
53 sourceNode.buffer = buffer;
54 sourceNode.start();
55
56 timePlaybackStarted = Date.now();
57
58 audioDecodedCallback(buffer);
59
60}

Related snippets