/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/microphone-stream@6.0.1/dist/microphone-stream.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};return function(e,o){function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}(),__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});var readable_stream_1=require("readable-stream"),buffer_from_1=__importDefault(require("buffer-from")),MicrophoneStream=function(t){function e(e){void 0===e&&(e={objectMode:!1});var o=t.call(this,{objectMode:e.objectMode})||this;o.audioInput=null,o.recording=!0;var r=e.stream,n=e.objectMode,i=e.bufferSize,c=e.context;o.objectMode=n,o.bufferSize=i||void 0===window.AudioContext?4096:null;var a=window.AudioContext||window.webkitAudioContext;o.context=c||new a;return o.recorder=o.context.createScriptProcessor(i,1,1),o.recorder.connect(o.context.destination),r&&o.setStream(r),setTimeout((function(){o.emit("format",{channels:1,bitDepth:32,sampleRate:o.context.sampleRate,signed:!0,float:!0})}),0),o}return __extends(e,t),e.prototype.setStream=function(t){var e=this;this.stream=t,this.audioInput=this.context.createMediaStreamSource(t),this.audioInput.connect(this.recorder);this.recorder.onaudioprocess=function(t){e.recording&&e.push(e.objectMode?t.inputBuffer:buffer_from_1.default(t.inputBuffer.getChannelData(0).buffer))}},e.prototype.pauseRecording=function(){this.recording=!1},e.prototype.playRecording=function(){this.recording=!0},e.prototype.stop=function(){if("closed"!==this.context.state){try{this.stream.getTracks()[0].stop()}catch(t){}this.recorder.disconnect(),this.audioInput&&this.audioInput.disconnect();try{this.context.close()}catch(t){}this.recording=!1,this.push(null),this.emit("close")}},e.prototype._read=function(){},e.toRaw=function(t){return new Float32Array(t.buffer)},e}(readable_stream_1.Readable);exports.default=MicrophoneStream;
//# sourceMappingURL=/sm/18a3ff8c44daa1b784e9a6c08a0a1e261393d8157968d9112fe6bc267ebd1034.map