Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/main/recorder/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/main/recorder/encoder.min.js |
var mp3Encoder;var mp3Buffer=[];onmessage=function(e){switch(e.data.action){case"init":init(e.data);break;case"start":start();break;case"record":record(e.data);break;case"stop":stop();break}};function init(e){var r=e.channels||1;var a=e.sampleRate||44100;var t=e.bitRate||128;if(e.type==="audio/mp3"){importScripts("/bitrix/js/main/recorder/lame.min.js");mp3Encoder=new lamejs.Mp3Encoder(r,a,t)}}function start(){mp3Buffer=[]}function record(e){var r=floatTo16BitPCM(e.input);var a=mp3Encoder.encodeBuffer(r);mp3Buffer.push(a)}function stop(){mp3Buffer.push(mp3Encoder.flush);var e=new Blob(mp3Buffer,{type:"audio/mpeg"});postMessage({action:"result",result:e});mp3Buffer=[]}function floatTo16BitPCM(e){var r=e.length;var a=new Int16Array(r);var t;for(var n=0;n<r;n++){if(e[n]>1)t=1;else if(e[n]<-1)t=-1;else t=e[n];a[n]=t>0?t*32767:t*32768}return a} //# sourceMappingURL=encoder.map.js