mattdiamond / Recorderjs

A plugin for recording/exporting the output of Web Audio API nodes
4.16k stars 1.46k forks source link

Uncaught ReferenceError: s is not defined #192

Open Blacktoviche opened 5 years ago

Blacktoviche commented 5 years ago

I'm using Recorderjs in react app everything is working fine but when I switch website to https I got this message Uncaught ReferenceError: s is not defined

var e=0,t=[],a=void 0,n=void 0;function r(){for(var e=0;e<n;e++)t[e]=[]}function o(e,t){for(var a=new Float32Array(t),n=0,s=0;s<e.length;s++)a.set(e[s],n),n+=e[s].length;return a}function i(e,t,a){for(var n=0;n<a.length;n++)e.setUint8(t+n,a.charCodeAt(n))}s.onmessage=function(l){switch(l.data.command){case"init":c=l.data.config,a=c.sampleRate,n=c.numChannels,r();break;case"record":!function(a){for(var s=0;s<n;s++)t[s].push(a[s]);e+=a[0].length}(l.data.buffer);break;case"exportWAV":!function(r){for(var l=[],c=0;c<n;c++)l.push(o(t[c],e));var d=function(e){var t=new ArrayBuffer(44+2*e.length),s=new DataView(t);return i(s,0,"RIFF"),s.setUint32(4,36+2*e.length,!0),i(s,8,"WAVE"),i(s,12,"fmt "),s.setUint32(16,16,!0),s.setUint16(20,1,!0),s.setUint16(22,n,!0),s.setUint32(24,a,!0),s.setUint32(28,4*a,!0),s.setUint16(32,2*n,!0),s.setUint16(34,16,!0),i(s,36,"data"),s.setUint32(40,2*e.length,!0),function(e,t,a){for(var n=0;n<a.length;n++,t+=2){var s=Math.max(-1,Math.min(1,a[n]));e.setInt16(t,s<0?32768*s:32767*s,!0)}}(s,44,e),s}(2===n?function(e,t){for(var a=e.length+t.length,n=new Float32Array(a),s=0,r=0;s<a;)n[s++]=e[r],n[s++]=t[r],r++;return n}(l[0],l[1]):l[0]),u=new Blob([d],{type:r});s.postMessage({command:"exportWAV",data:u})}(l.data.type);break;case"getBuffer":!function(){for(var a=[],r=0;r<n;r++)a.push(o(t[r],e));s.postMessage({command:"getBuffer",data:a})}();break;case"clear":e=0,t=[],r()}var c}

396f996e-6318-40fc-ba65-b17353b9bddd

The error caught on line 's.onmessage'

chasecs commented 5 years ago

Same issue. Maybe something relevant to javascript minification. In my situation, undo the minification then it works.

Blacktoviche commented 5 years ago

@chasecs As I'm using this library in ReactJS project I switched to this forked repository https://github.com/pindrop/Recorderjs Everything is fine now