@siteed/expo-audio-studio 2.8.0 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/app.plugin.cjs +15 -2
  3. package/build/cjs/AudioAnalysis/AudioAnalysis.types.js +4 -0
  4. package/build/cjs/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
  5. package/build/cjs/AudioAnalysis/extractAudioAnalysis.js +205 -0
  6. package/build/cjs/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
  7. package/build/cjs/AudioAnalysis/extractAudioData.js +12 -0
  8. package/build/cjs/AudioAnalysis/extractAudioData.js.map +1 -0
  9. package/build/cjs/AudioAnalysis/extractMelSpectrogram.js +89 -0
  10. package/build/cjs/AudioAnalysis/extractMelSpectrogram.js.map +1 -0
  11. package/build/cjs/AudioAnalysis/extractPreview.js +29 -0
  12. package/build/cjs/AudioAnalysis/extractPreview.js.map +1 -0
  13. package/build/cjs/AudioAnalysis/extractWaveform.js +18 -0
  14. package/build/cjs/AudioAnalysis/extractWaveform.js.map +1 -0
  15. package/build/cjs/AudioDeviceManager.js +500 -0
  16. package/build/cjs/AudioDeviceManager.js.map +1 -0
  17. package/build/cjs/AudioRecorder.provider.js +68 -0
  18. package/build/cjs/AudioRecorder.provider.js.map +1 -0
  19. package/build/cjs/ExpoAudioStream.native.js +8 -0
  20. package/build/cjs/ExpoAudioStream.native.js.map +1 -0
  21. package/build/cjs/ExpoAudioStream.types.js +11 -0
  22. package/build/cjs/ExpoAudioStream.types.js.map +1 -0
  23. package/build/cjs/ExpoAudioStream.web.js +705 -0
  24. package/build/cjs/ExpoAudioStream.web.js.map +1 -0
  25. package/build/cjs/ExpoAudioStreamModule.js +718 -0
  26. package/build/cjs/ExpoAudioStreamModule.js.map +1 -0
  27. package/build/cjs/WebRecorder.web.js +756 -0
  28. package/build/cjs/WebRecorder.web.js.map +1 -0
  29. package/build/cjs/constants.js +17 -0
  30. package/build/cjs/constants.js.map +1 -0
  31. package/build/cjs/events.js +30 -0
  32. package/build/cjs/events.js.map +1 -0
  33. package/build/cjs/hooks/useAudioDevices.js +155 -0
  34. package/build/cjs/hooks/useAudioDevices.js.map +1 -0
  35. package/build/cjs/index.js +50 -0
  36. package/build/cjs/index.js.map +1 -0
  37. package/build/cjs/trimAudio.js +75 -0
  38. package/build/cjs/trimAudio.js.map +1 -0
  39. package/build/cjs/useAudioRecorder.js +453 -0
  40. package/build/cjs/useAudioRecorder.js.map +1 -0
  41. package/build/cjs/utils/BlobFix.js +502 -0
  42. package/build/cjs/utils/BlobFix.js.map +1 -0
  43. package/build/cjs/utils/audioProcessing.js +137 -0
  44. package/build/cjs/utils/audioProcessing.js.map +1 -0
  45. package/build/cjs/utils/concatenateBuffers.js +25 -0
  46. package/build/cjs/utils/concatenateBuffers.js.map +1 -0
  47. package/build/cjs/utils/convertPCMToFloat32.js +124 -0
  48. package/build/cjs/utils/convertPCMToFloat32.js.map +1 -0
  49. package/build/cjs/utils/crc32.js +52 -0
  50. package/build/cjs/utils/crc32.js.map +1 -0
  51. package/build/cjs/utils/encodingToBitDepth.js +17 -0
  52. package/build/cjs/utils/encodingToBitDepth.js.map +1 -0
  53. package/build/cjs/utils/getWavFileInfo.js +96 -0
  54. package/build/cjs/utils/getWavFileInfo.js.map +1 -0
  55. package/build/cjs/utils/writeWavHeader.js +88 -0
  56. package/build/cjs/utils/writeWavHeader.js.map +1 -0
  57. package/build/cjs/workers/InlineFeaturesExtractor.web.js +853 -0
  58. package/build/cjs/workers/InlineFeaturesExtractor.web.js.map +1 -0
  59. package/build/cjs/workers/inlineAudioWebWorker.web.js +184 -0
  60. package/build/cjs/workers/inlineAudioWebWorker.web.js.map +1 -0
  61. package/build/esm/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
  62. package/build/esm/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
  63. package/build/esm/AudioAnalysis/extractAudioData.js.map +1 -0
  64. package/build/esm/AudioAnalysis/extractMelSpectrogram.js.map +1 -0
  65. package/build/esm/AudioAnalysis/extractPreview.js.map +1 -0
  66. package/build/esm/AudioAnalysis/extractWaveform.js.map +1 -0
  67. package/build/esm/AudioDeviceManager.js.map +1 -0
  68. package/build/esm/AudioRecorder.provider.js.map +1 -0
  69. package/build/esm/ExpoAudioStream.native.js.map +1 -0
  70. package/build/esm/ExpoAudioStream.types.js.map +1 -0
  71. package/build/esm/ExpoAudioStream.web.js.map +1 -0
  72. package/build/esm/ExpoAudioStreamModule.js.map +1 -0
  73. package/build/esm/WebRecorder.web.js.map +1 -0
  74. package/build/esm/constants.js.map +1 -0
  75. package/build/esm/events.js.map +1 -0
  76. package/build/esm/hooks/useAudioDevices.js.map +1 -0
  77. package/build/esm/index.js.map +1 -0
  78. package/build/esm/trimAudio.js.map +1 -0
  79. package/build/esm/useAudioRecorder.js.map +1 -0
  80. package/build/esm/utils/BlobFix.js.map +1 -0
  81. package/build/esm/utils/audioProcessing.js.map +1 -0
  82. package/build/esm/utils/concatenateBuffers.js.map +1 -0
  83. package/build/esm/utils/convertPCMToFloat32.js.map +1 -0
  84. package/build/esm/utils/crc32.js.map +1 -0
  85. package/build/esm/utils/encodingToBitDepth.js.map +1 -0
  86. package/build/esm/utils/getWavFileInfo.js.map +1 -0
  87. package/build/esm/utils/writeWavHeader.js.map +1 -0
  88. package/build/esm/workers/InlineFeaturesExtractor.web.js.map +1 -0
  89. package/build/esm/workers/inlineAudioWebWorker.web.js.map +1 -0
  90. package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -0
  91. package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -0
  92. package/build/types/AudioAnalysis/extractAudioData.d.ts.map +1 -0
  93. package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts.map +1 -0
  94. package/build/types/AudioAnalysis/extractPreview.d.ts.map +1 -0
  95. package/build/types/AudioAnalysis/extractWaveform.d.ts.map +1 -0
  96. package/build/types/AudioDeviceManager.d.ts.map +1 -0
  97. package/build/types/AudioRecorder.provider.d.ts.map +1 -0
  98. package/build/types/ExpoAudioStream.native.d.ts.map +1 -0
  99. package/build/types/ExpoAudioStream.types.d.ts.map +1 -0
  100. package/build/types/ExpoAudioStream.web.d.ts.map +1 -0
  101. package/build/types/ExpoAudioStreamModule.d.ts.map +1 -0
  102. package/build/types/WebRecorder.web.d.ts.map +1 -0
  103. package/build/types/constants.d.ts.map +1 -0
  104. package/build/types/events.d.ts.map +1 -0
  105. package/build/types/hooks/useAudioDevices.d.ts.map +1 -0
  106. package/build/types/index.d.ts.map +1 -0
  107. package/build/types/trimAudio.d.ts.map +1 -0
  108. package/build/types/useAudioRecorder.d.ts.map +1 -0
  109. package/build/types/utils/BlobFix.d.ts.map +1 -0
  110. package/build/types/utils/audioProcessing.d.ts.map +1 -0
  111. package/build/types/utils/concatenateBuffers.d.ts.map +1 -0
  112. package/build/types/utils/convertPCMToFloat32.d.ts.map +1 -0
  113. package/build/types/utils/crc32.d.ts.map +1 -0
  114. package/build/types/utils/encodingToBitDepth.d.ts.map +1 -0
  115. package/build/types/utils/getWavFileInfo.d.ts.map +1 -0
  116. package/build/types/utils/writeWavHeader.d.ts.map +1 -0
  117. package/build/types/workers/InlineFeaturesExtractor.web.d.ts.map +1 -0
  118. package/build/types/workers/inlineAudioWebWorker.web.d.ts.map +1 -0
  119. package/package.json +25 -7
  120. package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
  121. package/build/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
  122. package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
  123. package/build/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
  124. package/build/AudioAnalysis/extractAudioData.d.ts.map +0 -1
  125. package/build/AudioAnalysis/extractAudioData.js.map +0 -1
  126. package/build/AudioAnalysis/extractMelSpectrogram.d.ts.map +0 -1
  127. package/build/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
  128. package/build/AudioAnalysis/extractPreview.d.ts.map +0 -1
  129. package/build/AudioAnalysis/extractPreview.js.map +0 -1
  130. package/build/AudioAnalysis/extractWaveform.d.ts.map +0 -1
  131. package/build/AudioAnalysis/extractWaveform.js.map +0 -1
  132. package/build/AudioDeviceManager.d.ts.map +0 -1
  133. package/build/AudioDeviceManager.js.map +0 -1
  134. package/build/AudioRecorder.provider.d.ts.map +0 -1
  135. package/build/AudioRecorder.provider.js.map +0 -1
  136. package/build/ExpoAudioStream.native.d.ts.map +0 -1
  137. package/build/ExpoAudioStream.native.js.map +0 -1
  138. package/build/ExpoAudioStream.types.d.ts.map +0 -1
  139. package/build/ExpoAudioStream.types.js.map +0 -1
  140. package/build/ExpoAudioStream.web.d.ts.map +0 -1
  141. package/build/ExpoAudioStream.web.js.map +0 -1
  142. package/build/ExpoAudioStreamModule.d.ts.map +0 -1
  143. package/build/ExpoAudioStreamModule.js.map +0 -1
  144. package/build/WebRecorder.web.d.ts.map +0 -1
  145. package/build/WebRecorder.web.js.map +0 -1
  146. package/build/constants.d.ts.map +0 -1
  147. package/build/constants.js.map +0 -1
  148. package/build/events.d.ts.map +0 -1
  149. package/build/events.js.map +0 -1
  150. package/build/hooks/useAudioDevices.d.ts.map +0 -1
  151. package/build/hooks/useAudioDevices.js.map +0 -1
  152. package/build/index.d.ts.map +0 -1
  153. package/build/index.js.map +0 -1
  154. package/build/trimAudio.d.ts.map +0 -1
  155. package/build/trimAudio.js.map +0 -1
  156. package/build/useAudioRecorder.d.ts.map +0 -1
  157. package/build/useAudioRecorder.js.map +0 -1
  158. package/build/utils/BlobFix.d.ts.map +0 -1
  159. package/build/utils/BlobFix.js.map +0 -1
  160. package/build/utils/audioProcessing.d.ts.map +0 -1
  161. package/build/utils/audioProcessing.js.map +0 -1
  162. package/build/utils/concatenateBuffers.d.ts.map +0 -1
  163. package/build/utils/concatenateBuffers.js.map +0 -1
  164. package/build/utils/convertPCMToFloat32.d.ts.map +0 -1
  165. package/build/utils/convertPCMToFloat32.js.map +0 -1
  166. package/build/utils/crc32.d.ts.map +0 -1
  167. package/build/utils/crc32.js.map +0 -1
  168. package/build/utils/encodingToBitDepth.d.ts.map +0 -1
  169. package/build/utils/encodingToBitDepth.js.map +0 -1
  170. package/build/utils/getWavFileInfo.d.ts.map +0 -1
  171. package/build/utils/getWavFileInfo.js.map +0 -1
  172. package/build/utils/writeWavHeader.d.ts.map +0 -1
  173. package/build/utils/writeWavHeader.js.map +0 -1
  174. package/build/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
  175. package/build/workers/InlineFeaturesExtractor.web.js.map +0 -1
  176. package/build/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
  177. package/build/workers/inlineAudioWebWorker.web.js.map +0 -1
  178. /package/build/{AudioAnalysis → esm/AudioAnalysis}/AudioAnalysis.types.js +0 -0
  179. /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractAudioAnalysis.js +0 -0
  180. /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractAudioData.js +0 -0
  181. /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractMelSpectrogram.js +0 -0
  182. /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractPreview.js +0 -0
  183. /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractWaveform.js +0 -0
  184. /package/build/{AudioDeviceManager.js → esm/AudioDeviceManager.js} +0 -0
  185. /package/build/{AudioRecorder.provider.js → esm/AudioRecorder.provider.js} +0 -0
  186. /package/build/{ExpoAudioStream.native.js → esm/ExpoAudioStream.native.js} +0 -0
  187. /package/build/{ExpoAudioStream.types.js → esm/ExpoAudioStream.types.js} +0 -0
  188. /package/build/{ExpoAudioStream.web.js → esm/ExpoAudioStream.web.js} +0 -0
  189. /package/build/{ExpoAudioStreamModule.js → esm/ExpoAudioStreamModule.js} +0 -0
  190. /package/build/{WebRecorder.web.js → esm/WebRecorder.web.js} +0 -0
  191. /package/build/{constants.js → esm/constants.js} +0 -0
  192. /package/build/{events.js → esm/events.js} +0 -0
  193. /package/build/{hooks → esm/hooks}/useAudioDevices.js +0 -0
  194. /package/build/{index.js → esm/index.js} +0 -0
  195. /package/build/{trimAudio.js → esm/trimAudio.js} +0 -0
  196. /package/build/{useAudioRecorder.js → esm/useAudioRecorder.js} +0 -0
  197. /package/build/{utils → esm/utils}/BlobFix.js +0 -0
  198. /package/build/{utils → esm/utils}/audioProcessing.js +0 -0
  199. /package/build/{utils → esm/utils}/concatenateBuffers.js +0 -0
  200. /package/build/{utils → esm/utils}/convertPCMToFloat32.js +0 -0
  201. /package/build/{utils → esm/utils}/crc32.js +0 -0
  202. /package/build/{utils → esm/utils}/encodingToBitDepth.js +0 -0
  203. /package/build/{utils → esm/utils}/getWavFileInfo.js +0 -0
  204. /package/build/{utils → esm/utils}/writeWavHeader.js +0 -0
  205. /package/build/{workers → esm/workers}/InlineFeaturesExtractor.web.js +0 -0
  206. /package/build/{workers → esm/workers}/inlineAudioWebWorker.web.js +0 -0
  207. /package/build/{AudioAnalysis → types/AudioAnalysis}/AudioAnalysis.types.d.ts +0 -0
  208. /package/build/{AudioAnalysis → types/AudioAnalysis}/extractAudioAnalysis.d.ts +0 -0
  209. /package/build/{AudioAnalysis → types/AudioAnalysis}/extractAudioData.d.ts +0 -0
  210. /package/build/{AudioAnalysis → types/AudioAnalysis}/extractMelSpectrogram.d.ts +0 -0
  211. /package/build/{AudioAnalysis → types/AudioAnalysis}/extractPreview.d.ts +0 -0
  212. /package/build/{AudioAnalysis → types/AudioAnalysis}/extractWaveform.d.ts +0 -0
  213. /package/build/{AudioDeviceManager.d.ts → types/AudioDeviceManager.d.ts} +0 -0
  214. /package/build/{AudioRecorder.provider.d.ts → types/AudioRecorder.provider.d.ts} +0 -0
  215. /package/build/{ExpoAudioStream.native.d.ts → types/ExpoAudioStream.native.d.ts} +0 -0
  216. /package/build/{ExpoAudioStream.types.d.ts → types/ExpoAudioStream.types.d.ts} +0 -0
  217. /package/build/{ExpoAudioStream.web.d.ts → types/ExpoAudioStream.web.d.ts} +0 -0
  218. /package/build/{ExpoAudioStreamModule.d.ts → types/ExpoAudioStreamModule.d.ts} +0 -0
  219. /package/build/{WebRecorder.web.d.ts → types/WebRecorder.web.d.ts} +0 -0
  220. /package/build/{constants.d.ts → types/constants.d.ts} +0 -0
  221. /package/build/{events.d.ts → types/events.d.ts} +0 -0
  222. /package/build/{hooks → types/hooks}/useAudioDevices.d.ts +0 -0
  223. /package/build/{index.d.ts → types/index.d.ts} +0 -0
  224. /package/build/{trimAudio.d.ts → types/trimAudio.d.ts} +0 -0
  225. /package/build/{useAudioRecorder.d.ts → types/useAudioRecorder.d.ts} +0 -0
  226. /package/build/{utils → types/utils}/BlobFix.d.ts +0 -0
  227. /package/build/{utils → types/utils}/audioProcessing.d.ts +0 -0
  228. /package/build/{utils → types/utils}/concatenateBuffers.d.ts +0 -0
  229. /package/build/{utils → types/utils}/convertPCMToFloat32.d.ts +0 -0
  230. /package/build/{utils → types/utils}/crc32.d.ts +0 -0
  231. /package/build/{utils → types/utils}/encodingToBitDepth.d.ts +0 -0
  232. /package/build/{utils → types/utils}/getWavFileInfo.d.ts +0 -0
  233. /package/build/{utils → types/utils}/writeWavHeader.d.ts +0 -0
  234. /package/build/{workers → types/workers}/InlineFeaturesExtractor.web.d.ts +0 -0
  235. /package/build/{workers → types/workers}/inlineAudioWebWorker.web.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebRecorder.web.js","sourceRoot":"","sources":["../../src/WebRecorder.web.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAQpD,mEAA+D;AAC/D,2DAAuD;AACvD,uFAA+E;AAC/E,iFAAyE;AAmBzE,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAC/B,MAAM,2BAA2B,GAAG,GAAG,CAAA;AACvC,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAChC,MAAM,8BAA8B,GAAG,CAAC,CAAA;AAExC,MAAM,GAAG,GAAG,aAAa,CAAA;AAEzB,MAAa,WAAW;IACb,YAA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IAAI,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;YACxB,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,8BAA8B,QAAQ,UAAU,CAAC,CAAA;QACxE,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,2BAA2B,QAAQ,YAAY,CAAC,CAAA;QACtE,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,WAAW;QACP,OAAO,IAAI,CAAC,QAAQ,CAAA;IACxB,CAAC;IAED;;;OAGG;IACH,mBAAmB;QACf,OAAO,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAA;IACrC,CAAC;IAED;;;OAGG;IACH,mBAAmB,CAAC,MAAc;QAC9B,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,EAAE,KAAK,CACd,UAAU,MAAM,CAAC,MAAM,yCAAyC,CACnE,CAAA;YACD,IAAI,CAAC,gBAAgB,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAA;YAC7D,cAAc;YACd,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAC9C,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,EAClC,CAAC,CACJ,CAAA;QACL,CAAC;IACL,CAAC;CACJ;AAp6BD,kCAo6BC","sourcesContent":["// packages/expo-audio-stream/src/WebRecorder.web.ts\n\nimport { AudioAnalysis } from './AudioAnalysis/AudioAnalysis.types'\nimport { ConsoleLike, RecordingConfig } from './ExpoAudioStream.types'\nimport {\n EmitAudioAnalysisFunction,\n EmitAudioEventFunction,\n} from './ExpoAudioStream.web'\nimport { encodingToBitDepth } from './utils/encodingToBitDepth'\nimport { writeWavHeader } from './utils/writeWavHeader'\nimport { InlineFeaturesExtractor } from './workers/InlineFeaturesExtractor.web'\nimport { InlineAudioWebWorker } from './workers/inlineAudioWebWorker.web'\n\ninterface AudioWorkletEvent {\n data: {\n command: string\n recordedData?: Float32Array\n sampleRate?: number\n position?: number\n message?: string // For debug messages\n }\n}\n\ninterface AudioFeaturesEvent {\n data: {\n command: string\n result: AudioAnalysis\n }\n}\n\nconst DEFAULT_WEB_BITDEPTH = 32\nconst DEFAULT_SEGMENT_DURATION_MS = 100\nconst DEFAULT_WEB_INTERVAL = 500\nconst DEFAULT_WEB_NUMBER_OF_CHANNELS = 1\n\nconst TAG = 'WebRecorder'\n\nexport class WebRecorder {\n public audioContext: AudioContext\n private audioWorkletNode!: AudioWorkletNode\n private featureExtractorWorker?: Worker\n private source: MediaStreamAudioSourceNode\n private emitAudioEventCallback: EmitAudioEventFunction\n private emitAudioAnalysisCallback: EmitAudioAnalysisFunction\n private config: RecordingConfig\n private position: number = 0\n private numberOfChannels: number // Number of audio channels\n private bitDepth: number // Bit depth of the audio\n private exportBitDepth: number // Bit depth of the audio\n private audioAnalysisData: AudioAnalysis // Keep updating the full audio analysis data with latest events\n private logger?: ConsoleLike\n private compressedMediaRecorder: MediaRecorder | null = null\n private compressedChunks: Blob[] = []\n private compressedSize: number = 0\n private pendingCompressedChunk: Blob | null = null\n private dataPointIdCounter: number = 0 // Add this property to track the counter\n private deviceDisconnectionHandler: (() => void) | null = null\n private mediaStream: MediaStream | null = null\n private onInterruptionCallback?: (event: {\n reason: string\n isPaused: boolean\n timestamp: number\n }) => void\n private _isDeviceDisconnected: boolean = false\n private pcmData: Float32Array | null = null // Store original PCM data\n private totalSampleCount: number = 0\n\n /**\n * Flag to indicate whether this is the first audio chunk after a device switch\n * Used to maintain proper duration counting\n */\n public isFirstChunkAfterSwitch: boolean = false\n\n /**\n * Gets whether the recording device has been disconnected\n */\n get isDeviceDisconnected(): boolean {\n return this._isDeviceDisconnected\n }\n\n /**\n * Initializes a new WebRecorder instance for audio recording and processing\n * @param audioContext - The AudioContext to use for recording\n * @param source - The MediaStreamAudioSourceNode providing the audio input\n * @param recordingConfig - Configuration options for the recording\n * @param emitAudioEventCallback - Callback function for audio data events\n * @param emitAudioAnalysisCallback - Callback function for audio analysis events\n * @param onInterruption - Callback for recording interruptions\n * @param logger - Optional logger for debugging information\n */\n constructor({\n audioContext,\n source,\n recordingConfig,\n emitAudioEventCallback,\n emitAudioAnalysisCallback,\n onInterruption,\n logger,\n }: {\n audioContext: AudioContext\n source: MediaStreamAudioSourceNode\n recordingConfig: RecordingConfig\n emitAudioEventCallback: EmitAudioEventFunction\n emitAudioAnalysisCallback: EmitAudioAnalysisFunction\n onInterruption?: (event: {\n reason: string\n isPaused: boolean\n timestamp: number\n }) => void\n logger?: ConsoleLike\n }) {\n this.audioContext = audioContext\n this.source = source\n this.emitAudioEventCallback = emitAudioEventCallback\n this.emitAudioAnalysisCallback = emitAudioAnalysisCallback\n this.config = recordingConfig\n this.logger = logger\n\n const audioContextFormat = this.checkAudioContextFormat({\n sampleRate: this.audioContext.sampleRate,\n })\n this.logger?.debug('Initialized WebRecorder with config:', {\n sampleRate: audioContextFormat.sampleRate,\n bitDepth: audioContextFormat.bitDepth,\n numberOfChannels: audioContextFormat.numberOfChannels,\n })\n\n this.bitDepth = audioContextFormat.bitDepth\n this.numberOfChannels =\n audioContextFormat.numberOfChannels ||\n DEFAULT_WEB_NUMBER_OF_CHANNELS // Default to 1 if not available\n this.exportBitDepth =\n encodingToBitDepth({\n encoding: recordingConfig.encoding ?? 'pcm_32bit',\n }) ||\n audioContextFormat.bitDepth ||\n DEFAULT_WEB_BITDEPTH\n\n this.audioAnalysisData = {\n amplitudeRange: { min: 0, max: 0 },\n rmsRange: { min: 0, max: 0 },\n dataPoints: [],\n durationMs: 0,\n samples: 0,\n bitDepth: this.bitDepth,\n numberOfChannels: this.numberOfChannels,\n sampleRate: this.config.sampleRate || this.audioContext.sampleRate,\n segmentDurationMs:\n this.config.segmentDurationMs ?? DEFAULT_SEGMENT_DURATION_MS, // Default to 100ms segments\n }\n\n if (recordingConfig.enableProcessing) {\n this.initFeatureExtractorWorker()\n }\n\n // Initialize compressed recording if enabled\n if (recordingConfig.compression?.enabled) {\n this.initializeCompressedRecorder()\n }\n\n this.mediaStream = source.mediaStream\n this.onInterruptionCallback = onInterruption\n\n // Setup device disconnection detection\n this.setupDeviceDisconnectionDetection()\n }\n\n /**\n * Initializes the audio worklet using an inline script\n * Creates and connects the audio processing pipeline\n */\n async init() {\n try {\n // Create and use inline audio worklet\n const blob = new Blob([InlineAudioWebWorker], {\n type: 'application/javascript',\n })\n const url = URL.createObjectURL(blob)\n await this.audioContext.audioWorklet.addModule(url)\n\n this.audioWorkletNode = new AudioWorkletNode(\n this.audioContext,\n 'recorder-processor'\n )\n\n this.audioWorkletNode.port.onmessage = async (\n event: AudioWorkletEvent\n ) => {\n const command = event.data.command\n if (command === 'debug') {\n this.logger?.debug(`[AudioWorklet] ${event.data.message}`)\n return\n }\n\n if (command !== 'newData') return\n\n const pcmBufferFloat = event.data.recordedData\n if (!pcmBufferFloat) {\n this.logger?.warn('Received empty audio buffer', event)\n return\n }\n\n // Process data in smaller chunks and emit immediately\n const sampleRate =\n event.data.sampleRate ?? this.audioContext.sampleRate\n // Use chunk size from config interval or default to 2 seconds\n const intervalMs = this.config.interval ?? DEFAULT_WEB_INTERVAL\n const chunkSize = Math.floor(sampleRate * (intervalMs / 1000))\n const duration = pcmBufferFloat.length / sampleRate\n\n // Use incoming position if provided by worklet, otherwise use our tracked position\n const incomingPosition =\n typeof event.data.position === 'number'\n ? event.data.position\n : this.position\n\n // Calculate bytes per sample based on bit depth\n const bytesPerSample = this.bitDepth / 8\n\n // Emit chunks without storing them\n for (let i = 0; i < pcmBufferFloat.length; i += chunkSize) {\n const chunk = pcmBufferFloat.slice(i, i + chunkSize)\n const chunkPosition = incomingPosition + i / sampleRate\n\n // Calculate byte positions and samples\n const startPosition = Math.floor(i * bytesPerSample)\n const endPosition = Math.floor(\n (i + chunk.length) * bytesPerSample\n )\n const samples = chunk.length // Number of samples in this chunk\n\n // Process features if enabled\n if (\n this.config.enableProcessing &&\n this.featureExtractorWorker\n ) {\n this.featureExtractorWorker.postMessage({\n command: 'process',\n channelData: chunk,\n sampleRate,\n segmentDurationMs:\n this.config.segmentDurationMs ??\n DEFAULT_SEGMENT_DURATION_MS, // Default to 100ms\n bitDepth: this.bitDepth,\n fullAudioDurationMs: chunkPosition * 1000,\n numberOfChannels: this.numberOfChannels,\n features: this.config.features,\n intervalAnalysis: this.config.intervalAnalysis,\n startPosition,\n endPosition,\n samples,\n })\n }\n\n // Only store PCM data if web.storeUncompressedAudio is not explicitly false\n const shouldStoreUncompressed =\n this.config.web?.storeUncompressedAudio !== false\n\n // Store PCM chunks when needed\n if (shouldStoreUncompressed) {\n // Store the original Float32Array data for later WAV creation\n this.appendPcmData(chunk)\n this.totalSampleCount += chunk.length\n }\n\n // Emit chunk immediately\n this.emitAudioEventCallback({\n data: chunk,\n position: chunkPosition,\n compression: this.pendingCompressedChunk\n ? {\n data: this.pendingCompressedChunk,\n size: this.pendingCompressedChunk.size,\n totalSize: this.compressedSize,\n mimeType: 'audio/webm',\n format: 'opus',\n bitrate:\n this.config.compression?.bitrate ??\n 128000,\n }\n : undefined,\n })\n }\n\n // Update our position based on the worklet's position if provided\n this.position = incomingPosition + duration\n this.pendingCompressedChunk = null\n }\n\n // Ensure we use all relevant settings from config\n const recordSampleRate = this.audioContext.sampleRate\n const exportSampleRate =\n this.config.sampleRate ?? this.audioContext.sampleRate\n const channels = this.config.channels ?? this.numberOfChannels\n const interval = this.config.interval ?? DEFAULT_WEB_INTERVAL\n\n this.logger?.debug(`WebRecorder initialized with config:`, {\n recordSampleRate,\n exportSampleRate,\n bitDepth: this.bitDepth,\n exportBitDepth: this.exportBitDepth,\n channels,\n interval,\n position: this.position,\n deviceId: this.config.deviceId || 'default',\n compression: this.config.compression\n ? {\n enabled: this.config.compression.enabled,\n format: this.config.compression.format,\n bitrate: this.config.compression.bitrate,\n }\n : 'disabled',\n })\n\n // Initialize the worklet with all settings from config\n this.audioWorkletNode.port.postMessage({\n command: 'init',\n recordSampleRate,\n exportSampleRate,\n bitDepth: this.bitDepth,\n exportBitDepth: this.exportBitDepth,\n channels,\n interval,\n position: this.position, // Pass the current position to the processor\n enableLogging: true,\n })\n\n // Connect the source to the AudioWorkletNode and start recording\n this.source.connect(this.audioWorkletNode)\n this.audioWorkletNode.connect(this.audioContext.destination)\n } catch (error) {\n console.error(`[${TAG}] Failed to initialize WebRecorder`, error)\n }\n }\n\n /**\n * Append new PCM data to the existing buffer\n * @param newData New Float32Array data to append\n */\n private appendPcmData(newData: Float32Array): void {\n // Clone the incoming data to ensure it's not modified\n const dataToAdd = new Float32Array(newData)\n\n if (!this.pcmData) {\n // First chunk - create a copy to avoid references to original data\n this.pcmData = new Float32Array(dataToAdd)\n return\n }\n\n // Create a new buffer with increased size\n const newBuffer = new Float32Array(\n this.pcmData.length + dataToAdd.length\n )\n\n // Copy existing data\n newBuffer.set(this.pcmData)\n\n // Append new data\n newBuffer.set(dataToAdd, this.pcmData.length)\n\n // Replace existing buffer\n this.pcmData = newBuffer\n }\n\n /**\n * Initializes the feature extractor worker for audio analysis\n * Creates an inline worker from a blob for audio feature extraction\n */\n initFeatureExtractorWorker() {\n try {\n const blob = new Blob([InlineFeaturesExtractor], {\n type: 'application/javascript',\n })\n const url = URL.createObjectURL(blob)\n this.featureExtractorWorker = new Worker(url)\n this.featureExtractorWorker.onmessage =\n this.handleFeatureExtractorMessage.bind(this)\n this.featureExtractorWorker.onerror = (error) => {\n console.error(`[${TAG}] Feature extractor worker error:`, error)\n }\n\n // Initialize worker with counter if needed\n if (this.dataPointIdCounter > 0) {\n this.featureExtractorWorker.postMessage({\n command: 'resetCounter',\n value: this.dataPointIdCounter,\n })\n this.logger?.debug(\n `Initialized worker with counter value ${this.dataPointIdCounter}`\n )\n }\n\n this.logger?.log(\n 'Feature extractor worker initialized successfully'\n )\n } catch (error) {\n console.error(\n `[${TAG}] Failed to initialize feature extractor worker`,\n error\n )\n }\n }\n\n /**\n * Processes audio analysis results from the feature extractor worker\n * Updates the audio analysis data and emits events\n * @param event - The event containing audio analysis results\n */\n handleFeatureExtractorMessage(event: AudioFeaturesEvent) {\n if (event.data.command === 'features') {\n const segmentResult = event.data.result\n\n // Track existing IDs to prevent duplicates\n const existingIds = new Set(\n this.audioAnalysisData.dataPoints.map((dp) => dp.id)\n )\n\n // Filter out datapoints with duplicate IDs\n const uniqueNewDataPoints = segmentResult.dataPoints.filter(\n (dp) => {\n return !existingIds.has(dp.id)\n }\n )\n\n // Log filtered duplicates if any\n if (\n uniqueNewDataPoints.length < segmentResult.dataPoints.length &&\n this.logger?.warn\n ) {\n this.logger.warn(\n `Filtered ${segmentResult.dataPoints.length - uniqueNewDataPoints.length} duplicate datapoints`\n )\n }\n\n // Update counter based on the highest ID seen\n if (uniqueNewDataPoints.length > 0) {\n const lastDataPoint =\n uniqueNewDataPoints[uniqueNewDataPoints.length - 1]\n\n if (lastDataPoint && typeof lastDataPoint.id === 'number') {\n const nextIdValue = lastDataPoint.id + 1\n\n if (nextIdValue > this.dataPointIdCounter) {\n this.dataPointIdCounter = nextIdValue\n this.logger?.debug(\n `Counter updated to ${this.dataPointIdCounter}`\n )\n }\n }\n }\n\n // Add unique data points to our analysis data\n this.audioAnalysisData.dataPoints.push(...uniqueNewDataPoints)\n this.audioAnalysisData.durationMs += segmentResult.durationMs\n this.audioAnalysisData.sampleRate = segmentResult.sampleRate\n\n // Merge amplitude ranges\n if (segmentResult.amplitudeRange) {\n if (!this.audioAnalysisData.amplitudeRange) {\n this.audioAnalysisData.amplitudeRange = {\n ...segmentResult.amplitudeRange,\n }\n } else {\n this.audioAnalysisData.amplitudeRange = {\n min: Math.min(\n this.audioAnalysisData.amplitudeRange.min,\n segmentResult.amplitudeRange.min\n ),\n max: Math.max(\n this.audioAnalysisData.amplitudeRange.max,\n segmentResult.amplitudeRange.max\n ),\n }\n }\n }\n\n // Merge RMS ranges\n if (segmentResult.rmsRange) {\n if (!this.audioAnalysisData.rmsRange) {\n this.audioAnalysisData.rmsRange = {\n ...segmentResult.rmsRange,\n }\n } else {\n this.audioAnalysisData.rmsRange = {\n min: Math.min(\n this.audioAnalysisData.rmsRange.min,\n segmentResult.rmsRange.min\n ),\n max: Math.max(\n this.audioAnalysisData.rmsRange.max,\n segmentResult.rmsRange.max\n ),\n }\n }\n }\n\n // Send filtered result to avoid duplicate IDs\n const filteredSegmentResult = {\n ...segmentResult,\n dataPoints: uniqueNewDataPoints,\n }\n\n this.emitAudioAnalysisCallback(filteredSegmentResult)\n }\n }\n\n /**\n * Reset the data point counter to a specific value or zero\n * @param startCounterFrom Optional value to start the counter from (for continuing from previous recordings)\n */\n resetDataPointCounter(startCounterFrom?: number): void {\n // Set the counter with the passed value or 0\n this.dataPointIdCounter =\n startCounterFrom !== undefined ? startCounterFrom : 0\n this.logger?.debug(\n `Reset data point counter to ${this.dataPointIdCounter}`\n )\n\n // Update worker counter if available\n if (this.featureExtractorWorker) {\n this.featureExtractorWorker.postMessage({\n command: 'resetCounter',\n value: this.dataPointIdCounter,\n })\n } else {\n this.logger?.warn(\n 'No feature extractor worker available to update counter'\n )\n }\n }\n\n /**\n * Get the current data point counter value\n * @returns The current value of the data point counter\n */\n getDataPointCounter(): number {\n return this.dataPointIdCounter\n }\n\n /**\n * Prepares the recorder for continuity after device switch\n * Sets up all necessary state to maintain proper recording continuity\n */\n prepareForDeviceSwitch(): void {\n this.isFirstChunkAfterSwitch = true\n this.logger?.debug(\n `Prepared for device switch at position ${this.position}s`\n )\n }\n\n /**\n * Starts the audio recording process\n * Connects the audio nodes and begins capturing audio data\n * @param preserveCounters If true, do not reset the counter (used for device switching)\n */\n start(preserveCounters = false) {\n this.source.connect(this.audioWorkletNode)\n this.audioWorkletNode.connect(this.audioContext.destination)\n\n // Only reset the counter when not preserving state (e.g., for a fresh recording)\n if (!preserveCounters) {\n this.logger?.debug(\n 'Starting fresh recording, resetting counter to 0'\n )\n this.resetDataPointCounter(0) // Explicitly reset to 0 for new recordings\n this.isFirstChunkAfterSwitch = false\n\n // Clear PCM data for new recording\n this.pcmData = null\n this.totalSampleCount = 0\n } else {\n this.logger?.debug(\n `Preserving counter at ${this.dataPointIdCounter} during device switch`\n )\n }\n\n if (this.compressedMediaRecorder) {\n this.compressedMediaRecorder.start(this.config.interval ?? 1000)\n }\n }\n\n /**\n * Creates a WAV file from the stored PCM data\n */\n private createWavFromPcmData(): Blob | null {\n try {\n // Check if we have PCM data\n if (!this.pcmData || this.pcmData.length === 0) {\n this.logger?.warn('No PCM data available to create WAV file')\n return null\n }\n\n const sampleRate =\n this.config.sampleRate || this.audioContext.sampleRate\n const channels = this.numberOfChannels || 1\n\n // Convert float32 PCM data to 16-bit PCM for WAV\n const bytesPerSample = 2 // 16-bit = 2 bytes\n const dataLength = this.pcmData.length * bytesPerSample\n const buffer = new ArrayBuffer(dataLength)\n const view = new DataView(buffer)\n\n // Convert Float32Array (-1 to 1) to Int16Array (-32768 to 32767)\n for (let i = 0; i < this.pcmData.length; i++) {\n const sample = Math.max(-1, Math.min(1, this.pcmData[i]))\n const int16Value = Math.round(sample * 32767)\n view.setInt16(i * 2, int16Value, true)\n }\n\n // Use the existing writeWavHeader utility to add a WAV header\n const wavBuffer = writeWavHeader({\n buffer,\n sampleRate,\n numChannels: channels,\n bitDepth: 16,\n isFloat: false,\n })\n\n return new Blob([wavBuffer], { type: 'audio/wav' })\n } catch (error) {\n this.logger?.error('Error creating WAV file from PCM data:', error)\n return null\n }\n }\n\n /**\n * Stops the audio recording process and returns the recorded data\n * @returns Promise resolving to an object containing compressed and/or uncompressed blobs\n */\n async stop(): Promise<{ compressedBlob?: Blob; uncompressedBlob?: Blob }> {\n try {\n // Stop any compressed recording first\n if (\n this.compressedMediaRecorder &&\n this.compressedMediaRecorder.state !== 'inactive'\n ) {\n this.compressedMediaRecorder.stop()\n }\n\n // Wait for any pending compressed chunks to be processed\n if (this.compressedMediaRecorder) {\n // Small delay to ensure all data is processed\n await new Promise((resolve) => setTimeout(resolve, 100))\n }\n\n // Create uncompressed WAV file from the PCM data\n let uncompressedBlob: Blob | undefined\n\n // Only create WAV if we have PCM data\n if (this.pcmData && this.pcmData.length > 0) {\n uncompressedBlob =\n (await this.createWavFromPcmData()) || undefined\n }\n\n // Return the compressed and/or uncompressed blobs if available\n return {\n compressedBlob:\n this.compressedChunks.length > 0\n ? new Blob(this.compressedChunks, {\n type: 'audio/webm;codecs=opus',\n })\n : undefined,\n uncompressedBlob,\n }\n } finally {\n this.cleanup()\n // Reset the chunks array\n this.compressedChunks = []\n this.compressedSize = 0\n this.pendingCompressedChunk = null\n this.pcmData = null\n this.totalSampleCount = 0\n }\n }\n\n /**\n * Cleans up resources when recording is stopped\n * Closes audio context and disconnects nodes\n */\n public cleanup() {\n // Remove device disconnection handler\n if (this.deviceDisconnectionHandler) {\n this.deviceDisconnectionHandler()\n this.deviceDisconnectionHandler = null\n }\n\n // Check if AudioContext is already closed before attempting to close it\n if (this.audioContext && this.audioContext.state !== 'closed') {\n try {\n this.audioContext.close()\n } catch (e) {\n // Ignore closure errors - this happens if already closed\n }\n }\n\n // Safely disconnect audioWorkletNode if it exists\n if (this.audioWorkletNode) {\n try {\n this.audioWorkletNode.disconnect()\n } catch (e) {\n // Ignore disconnection errors - node might be already disconnected\n }\n }\n\n // Safely disconnect source if it exists\n if (this.source) {\n try {\n this.source.disconnect()\n } catch (e) {\n // Ignore disconnection errors - source might be already disconnected\n }\n }\n\n // Always stop media stream tracks to release hardware resources\n this.stopMediaStreamTracks()\n\n // Mark as disconnected to prevent future errors\n this._isDeviceDisconnected = true\n }\n\n /**\n * Pauses the audio recording process\n * Disconnects audio nodes and pauses the media recorder\n */\n pause() {\n try {\n // Note: We're just pausing, not disconnecting the device\n // Simply disconnect nodes temporarily without marking device as disconnected\n this.source.disconnect(this.audioWorkletNode)\n this.audioWorkletNode.disconnect(this.audioContext.destination)\n this.audioWorkletNode.port.postMessage({ command: 'pause' })\n\n if (this.compressedMediaRecorder?.state === 'recording') {\n this.compressedMediaRecorder.pause()\n }\n\n this.logger?.debug('Recording paused successfully')\n } catch (error) {\n this.logger?.error('Error in pause(): ', error)\n // Already disconnected, just ignore and continue\n }\n }\n\n /**\n * Stops all media stream tracks to release hardware resources\n * Ensures recording indicators (like microphone icon) are turned off\n */\n public stopMediaStreamTracks() {\n // Stop all audio tracks to stop the recording icon\n if (this.mediaStream) {\n const tracks = this.mediaStream.getTracks()\n tracks.forEach((track) => track.stop())\n } else if (this.source?.mediaStream) {\n const tracks = this.source.mediaStream.getTracks()\n tracks.forEach((track) => track.stop())\n }\n }\n\n /**\n * Determines the audio format capabilities of the current audio context\n * @param sampleRate - The sample rate to check\n * @returns Object containing format information (sample rate, bit depth, channels)\n */\n private checkAudioContextFormat({ sampleRate }: { sampleRate: number }) {\n // Create a silent AudioBuffer\n const frameCount = sampleRate * 1.0 // 1 second buffer\n const audioBuffer = this.audioContext.createBuffer(\n 1,\n frameCount,\n sampleRate\n )\n\n // Check the format\n const channelData = audioBuffer.getChannelData(0)\n const bitDepth = channelData.BYTES_PER_ELEMENT * 8 // 4 bytes per element means 32-bit\n\n return {\n sampleRate: audioBuffer.sampleRate,\n bitDepth,\n numberOfChannels: audioBuffer.numberOfChannels,\n }\n }\n\n /**\n * Resumes a paused recording\n * Reconnects audio nodes and resumes the media recorder\n */\n resume() {\n // If device was disconnected, we can't resume\n if (this._isDeviceDisconnected) {\n this.logger?.warn('Cannot resume recording: device disconnected')\n return\n }\n\n try {\n this.source.connect(this.audioWorkletNode)\n this.audioWorkletNode.connect(this.audioContext.destination)\n this.audioWorkletNode.port.postMessage({ command: 'resume' })\n this.compressedMediaRecorder?.resume()\n } catch (error) {\n this.logger?.error('Error in resume(): ', error)\n }\n }\n\n /**\n * Initializes the compressed media recorder if compression is enabled\n * Sets up event handlers for compressed audio data\n */\n private initializeCompressedRecorder() {\n try {\n const mimeType = 'audio/webm;codecs=opus'\n if (!MediaRecorder.isTypeSupported(mimeType)) {\n this.logger?.warn(\n 'Opus compression not supported in this browser'\n )\n return\n }\n\n this.compressedMediaRecorder = new MediaRecorder(\n this.source.mediaStream,\n {\n mimeType,\n audioBitsPerSecond:\n this.config.compression?.bitrate ?? 128000,\n }\n )\n\n this.compressedMediaRecorder.ondataavailable = (event) => {\n if (event.data.size > 0) {\n this.compressedChunks.push(event.data)\n this.compressedSize += event.data.size\n this.pendingCompressedChunk = event.data\n }\n }\n } catch (error) {\n this.logger?.error(\n 'Failed to initialize compressed recorder:',\n error\n )\n }\n }\n\n /**\n * Processes features if enabled\n */\n processFeatures(\n chunk: Float32Array,\n sampleRate: number,\n chunkPosition: number,\n startPosition: number,\n endPosition: number,\n samples: number\n ) {\n if (this.config.enableProcessing && this.featureExtractorWorker) {\n this.featureExtractorWorker.postMessage({\n command: 'process',\n channelData: chunk,\n sampleRate,\n segmentDurationMs:\n this.config.segmentDurationMs ??\n DEFAULT_SEGMENT_DURATION_MS, // Default to 100ms\n bitDepth: this.bitDepth,\n fullAudioDurationMs: chunkPosition * 1000,\n numberOfChannels: this.numberOfChannels,\n features: this.config.features,\n intervalAnalysis: this.config.intervalAnalysis,\n startPosition,\n endPosition,\n samples,\n })\n }\n }\n\n /**\n * Sets up detection for device disconnection events\n */\n private setupDeviceDisconnectionDetection() {\n if (!this.mediaStream) return\n\n // Function to handle track ending (which happens on device disconnection)\n const handleTrackEnded = () => {\n this.logger?.warn('Audio track ended - device disconnected')\n this._isDeviceDisconnected = true\n\n // Use the callback to notify parent component about device disconnection\n if (this.onInterruptionCallback) {\n this.onInterruptionCallback({\n reason: 'deviceDisconnected',\n isPaused: true,\n timestamp: Date.now(),\n })\n this.logger?.debug('Notified about device disconnection')\n }\n\n // Ensure we disconnect nodes to prevent zombie recordings\n if (this.audioWorkletNode) {\n this.audioWorkletNode.port.postMessage({\n command: 'deviceDisconnected',\n })\n\n try {\n this.source.disconnect(this.audioWorkletNode)\n this.audioWorkletNode.disconnect()\n } catch (e) {\n // Ignore disconnection errors as the track might already be gone\n }\n }\n }\n\n // Add listeners to all audio tracks\n const tracks = this.mediaStream.getAudioTracks()\n tracks.forEach((track) => {\n track.addEventListener('ended', handleTrackEnded)\n })\n\n // Store the handler for cleanup\n this.deviceDisconnectionHandler = () => {\n tracks.forEach((track) => {\n track.removeEventListener('ended', handleTrackEnded)\n })\n }\n }\n\n /**\n * Explicitly set the position for continuous recording across device switches\n * @param position The position in seconds to continue from\n */\n setPosition(position: number): void {\n if (position >= 0) {\n this.position = position\n this.logger?.debug(`Position explicitly set to ${position} seconds`)\n } else {\n this.logger?.warn(`Invalid position value: ${position}, ignoring`)\n }\n }\n\n /**\n * Get the current position in seconds\n * @returns The current position\n */\n getPosition(): number {\n return this.position\n }\n\n /**\n * Gets the current compressed chunks\n * @returns Array of current compressed audio chunks\n */\n getCompressedChunks(): Blob[] {\n return [...this.compressedChunks]\n }\n\n /**\n * Sets the compressed chunks from a previous recorder\n * @param chunks Array of compressed chunks from a previous recorder\n */\n setCompressedChunks(chunks: Blob[]): void {\n if (chunks && chunks.length > 0) {\n this.logger?.debug(\n `Adding ${chunks.length} compressed chunks from previous device`\n )\n this.compressedChunks = [...chunks, ...this.compressedChunks]\n // Update size\n this.compressedSize = this.compressedChunks.reduce(\n (size, chunk) => size + chunk.size,\n 0\n )\n }\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_BIT_DEPTH = exports.DEFAULT_SAMPLE_RATE = exports.INFO_CHUNK_ID = exports.DATA_CHUNK_ID = exports.FMT_CHUNK_ID = exports.WAVE_HEADER = exports.RIFF_HEADER = exports.DEBUG_NAMESPACE = exports.isWeb = void 0;
4
+ // packages/expo-audio-stream/src/constants.ts
5
+ const react_native_1 = require("react-native");
6
+ exports.isWeb = react_native_1.Platform.OS === 'web';
7
+ exports.DEBUG_NAMESPACE = 'expo-audio-stream';
8
+ // Constants for identifying chunks in a WAV file
9
+ exports.RIFF_HEADER = 0x52494646; // "RIFF"
10
+ exports.WAVE_HEADER = 0x57415645; // "WAVE"
11
+ exports.FMT_CHUNK_ID = 0x666d7420; // "fmt "
12
+ exports.DATA_CHUNK_ID = 0x64617461; // "data"
13
+ exports.INFO_CHUNK_ID = 0x494e464f; // "INFO"
14
+ // Default values
15
+ exports.DEFAULT_SAMPLE_RATE = 16000;
16
+ exports.DEFAULT_BIT_DEPTH = 32;
17
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AAC9C,+CAAuC;AAI1B,QAAA,KAAK,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAA;AAC7B,QAAA,eAAe,GAAG,mBAAmB,CAAA;AAElD,iDAAiD;AACpC,QAAA,WAAW,GAAG,UAAU,CAAA,CAAC,SAAS;AAClC,QAAA,WAAW,GAAG,UAAU,CAAA,CAAC,SAAS;AAClC,QAAA,YAAY,GAAG,UAAU,CAAA,CAAC,SAAS;AACnC,QAAA,aAAa,GAAG,UAAU,CAAA,CAAC,SAAS;AACpC,QAAA,aAAa,GAAG,UAAU,CAAA,CAAC,SAAS;AAEjD,iBAAiB;AACJ,QAAA,mBAAmB,GAAe,KAAK,CAAA;AACvC,QAAA,iBAAiB,GAAa,EAAE,CAAA","sourcesContent":["// packages/expo-audio-stream/src/constants.ts\nimport { Platform } from 'react-native'\n\nimport { BitDepth, SampleRate } from './ExpoAudioStream.types'\n\nexport const isWeb = Platform.OS === 'web'\nexport const DEBUG_NAMESPACE = 'expo-audio-stream'\n\n// Constants for identifying chunks in a WAV file\nexport const RIFF_HEADER = 0x52494646 // \"RIFF\"\nexport const WAVE_HEADER = 0x57415645 // \"WAVE\"\nexport const FMT_CHUNK_ID = 0x666d7420 // \"fmt \"\nexport const DATA_CHUNK_ID = 0x64617461 // \"data\"\nexport const INFO_CHUNK_ID = 0x494e464f // \"INFO\"\n\n// Default values\nexport const DEFAULT_SAMPLE_RATE: SampleRate = 16000\nexport const DEFAULT_BIT_DEPTH: BitDepth = 32\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // packages/expo-audio-stream/src/events.ts
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.addRecordingInterruptionListener = exports.addAudioAnalysisListener = exports.addAudioEventListener = void 0;
8
+ const expo_modules_core_1 = require("expo-modules-core");
9
+ const ExpoAudioStreamModule_1 = __importDefault(require("./ExpoAudioStreamModule"));
10
+ const emitter = new expo_modules_core_1.LegacyEventEmitter(ExpoAudioStreamModule_1.default);
11
+ function addAudioEventListener(listener) {
12
+ return emitter.addListener('AudioData', listener);
13
+ }
14
+ exports.addAudioEventListener = addAudioEventListener;
15
+ function addAudioAnalysisListener(listener) {
16
+ return emitter.addListener('AudioAnalysis', listener);
17
+ }
18
+ exports.addAudioAnalysisListener = addAudioAnalysisListener;
19
+ function addRecordingInterruptionListener(listener) {
20
+ // Add debug logging
21
+ console.debug('Adding recording interruption listener');
22
+ const subscription = emitter.addListener('onRecordingInterrupted', // Make sure this matches the native event name
23
+ (event) => {
24
+ console.debug('Recording interruption event received:', event);
25
+ listener(event);
26
+ });
27
+ return subscription;
28
+ }
29
+ exports.addRecordingInterruptionListener = addRecordingInterruptionListener;
30
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":";AAAA,2CAA2C;;;;;;AAE3C,yDAA8E;AAI9E,oFAA2D;AAE3D,MAAM,OAAO,GAAG,IAAI,sCAAkB,CAAC,+BAAqB,CAAC,CAAA;AAqB7D,SAAgB,qBAAqB,CACjC,QAAqD;IAErD,OAAO,OAAO,CAAC,WAAW,CAAoB,WAAW,EAAE,QAAQ,CAAC,CAAA;AACxE,CAAC;AAJD,sDAIC;AAKD,SAAgB,wBAAwB,CACpC,QAAsD;IAEtD,OAAO,OAAO,CAAC,WAAW,CAAqB,eAAe,EAAE,QAAQ,CAAC,CAAA;AAC7E,CAAC;AAJD,4DAIC;AAED,SAAgB,gCAAgC,CAC5C,QAAqD;IAErD,oBAAoB;IACpB,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAA;IAEvD,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CACpC,wBAAwB,EAAE,+CAA+C;IACzE,CAAC,KAAK,EAAE,EAAE;QACN,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAA;QAC9D,QAAQ,CAAC,KAAK,CAAC,CAAA;IACnB,CAAC,CACJ,CAAA;IAED,OAAO,YAAY,CAAA;AACvB,CAAC;AAfD,4EAeC","sourcesContent":["// packages/expo-audio-stream/src/events.ts\n\nimport { LegacyEventEmitter, type EventSubscription } from 'expo-modules-core'\n\nimport { AudioAnalysis } from './AudioAnalysis/AudioAnalysis.types'\nimport { RecordingInterruptionEvent } from './ExpoAudioStream.types'\nimport ExpoAudioStreamModule from './ExpoAudioStreamModule'\n\nconst emitter = new LegacyEventEmitter(ExpoAudioStreamModule)\n\n// Internal event payload from native module\nexport interface AudioEventPayload {\n encoded?: string\n buffer?: Float32Array\n fileUri: string\n lastEmittedSize: number\n position: number\n deltaSize: number\n totalSize: number\n mimeType: string\n streamUuid: string\n compression?: {\n data?: string | Blob // Base64 (native) or Float32Array (web) encoded compressed data chunk\n position: number\n eventDataSize: number\n totalSize: number\n }\n}\n\nexport function addAudioEventListener(\n listener: (event: AudioEventPayload) => Promise<void>\n): EventSubscription {\n return emitter.addListener<AudioEventPayload>('AudioData', listener)\n}\n\n// Only aliasing the AudioAnalysis type for the event payload\nexport interface AudioAnalysisEvent extends AudioAnalysis {}\n\nexport function addAudioAnalysisListener(\n listener: (event: AudioAnalysisEvent) => Promise<void>\n): EventSubscription {\n return emitter.addListener<AudioAnalysisEvent>('AudioAnalysis', listener)\n}\n\nexport function addRecordingInterruptionListener(\n listener: (event: RecordingInterruptionEvent) => void\n): EventSubscription {\n // Add debug logging\n console.debug('Adding recording interruption listener')\n\n const subscription = emitter.addListener<RecordingInterruptionEvent>(\n 'onRecordingInterrupted', // Make sure this matches the native event name\n (event) => {\n console.debug('Recording interruption event received:', event)\n listener(event)\n }\n )\n\n return subscription\n}\n"]}
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAudioDevices = void 0;
4
+ const react_1 = require("react");
5
+ const AudioDeviceManager_1 = require("../AudioDeviceManager");
6
+ /**
7
+ * React hook for managing audio input devices
8
+ */
9
+ function useAudioDevices() {
10
+ const [devices, setDevices] = (0, react_1.useState)([]);
11
+ const [currentDevice, setCurrentDevice] = (0, react_1.useState)(null);
12
+ const [loading, setLoading] = (0, react_1.useState)(true);
13
+ const [error, setError] = (0, react_1.useState)(null);
14
+ // Load devices on mount
15
+ (0, react_1.useEffect)(() => {
16
+ let isMounted = true;
17
+ const loadDevices = async () => {
18
+ try {
19
+ setLoading(true);
20
+ setError(null);
21
+ // Load available devices
22
+ const availableDevices = await AudioDeviceManager_1.audioDeviceManager.getAvailableDevices();
23
+ if (isMounted)
24
+ setDevices(availableDevices);
25
+ // Get current device
26
+ const device = await AudioDeviceManager_1.audioDeviceManager.getCurrentDevice();
27
+ if (isMounted)
28
+ setCurrentDevice(device);
29
+ }
30
+ catch (err) {
31
+ console.error('Failed to load audio devices:', err);
32
+ if (isMounted)
33
+ setError(err instanceof Error
34
+ ? err
35
+ : new Error('Failed to load audio devices'));
36
+ }
37
+ finally {
38
+ if (isMounted)
39
+ setLoading(false);
40
+ }
41
+ };
42
+ loadDevices();
43
+ // Set up device change listener
44
+ const removeListener = AudioDeviceManager_1.audioDeviceManager.addDeviceChangeListener((updatedDevices) => {
45
+ if (isMounted) {
46
+ setDevices(updatedDevices);
47
+ // If our current device is no longer available, update it
48
+ if (currentDevice &&
49
+ !updatedDevices.some((d) => d.id === currentDevice.id)) {
50
+ AudioDeviceManager_1.audioDeviceManager
51
+ .getCurrentDevice()
52
+ .then((newDevice) => {
53
+ if (isMounted)
54
+ setCurrentDevice(newDevice);
55
+ });
56
+ }
57
+ }
58
+ });
59
+ return () => {
60
+ isMounted = false;
61
+ removeListener();
62
+ };
63
+ }, []);
64
+ /**
65
+ * Select a specific audio input device
66
+ * @param deviceId The ID of the device to select
67
+ * @returns Promise resolving to a boolean indicating success
68
+ */
69
+ const selectDevice = (0, react_1.useCallback)(async (deviceId) => {
70
+ try {
71
+ setLoading(true);
72
+ setError(null);
73
+ const success = await AudioDeviceManager_1.audioDeviceManager.selectDevice(deviceId);
74
+ if (success) {
75
+ // Get the updated current device after selection
76
+ const device = await AudioDeviceManager_1.audioDeviceManager.getCurrentDevice();
77
+ setCurrentDevice(device);
78
+ }
79
+ return success;
80
+ }
81
+ catch (err) {
82
+ console.error('Failed to select audio device:', err);
83
+ setError(err instanceof Error
84
+ ? err
85
+ : new Error('Failed to select audio device'));
86
+ return false;
87
+ }
88
+ finally {
89
+ setLoading(false);
90
+ }
91
+ }, []);
92
+ /**
93
+ * Reset to the default audio input device
94
+ * @returns Promise resolving to a boolean indicating success
95
+ */
96
+ const resetToDefaultDevice = (0, react_1.useCallback)(async () => {
97
+ try {
98
+ setLoading(true);
99
+ setError(null);
100
+ const success = await AudioDeviceManager_1.audioDeviceManager.resetToDefaultDevice();
101
+ if (success) {
102
+ // Get the updated current device after reset
103
+ const device = await AudioDeviceManager_1.audioDeviceManager.getCurrentDevice();
104
+ setCurrentDevice(device);
105
+ }
106
+ return success;
107
+ }
108
+ catch (err) {
109
+ console.error('Failed to reset to default audio device:', err);
110
+ setError(err instanceof Error
111
+ ? err
112
+ : new Error('Failed to reset to default audio device'));
113
+ return false;
114
+ }
115
+ finally {
116
+ setLoading(false);
117
+ }
118
+ }, []);
119
+ /**
120
+ * Refresh the list of available devices
121
+ */
122
+ const refreshDevices = (0, react_1.useCallback)(async () => {
123
+ try {
124
+ setLoading(true);
125
+ setError(null);
126
+ const updatedDevices = await AudioDeviceManager_1.audioDeviceManager.refreshDevices();
127
+ setDevices(updatedDevices);
128
+ // Also refresh the current device
129
+ const device = await AudioDeviceManager_1.audioDeviceManager.getCurrentDevice();
130
+ setCurrentDevice(device);
131
+ return updatedDevices;
132
+ }
133
+ catch (err) {
134
+ console.error('Failed to refresh audio devices:', err);
135
+ setError(err instanceof Error
136
+ ? err
137
+ : new Error('Failed to refresh audio devices'));
138
+ return [];
139
+ }
140
+ finally {
141
+ setLoading(false);
142
+ }
143
+ }, []);
144
+ return {
145
+ devices,
146
+ currentDevice,
147
+ loading,
148
+ error,
149
+ selectDevice,
150
+ resetToDefaultDevice,
151
+ refreshDevices,
152
+ };
153
+ }
154
+ exports.useAudioDevices = useAudioDevices;
155
+ //# sourceMappingURL=useAudioDevices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAudioDevices.js","sourceRoot":"","sources":["../../../src/hooks/useAudioDevices.ts"],"names":[],"mappings":";;;AAAA,iCAAwD;AAExD,8DAA0D;AAG1D;;GAEG;AACH,SAAgB,eAAe;IAC3B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAgB,EAAE,CAAC,CAAA;IACzD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAqB,IAAI,CAAC,CAAA;IAC5E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAA;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAe,IAAI,CAAC,CAAA;IAEtD,wBAAwB;IACxB,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,SAAS,GAAG,IAAI,CAAA;QAEpB,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE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ACP,UAAU,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO;QACH,OAAO;QACP,aAAa;QACb,OAAO;QACP,KAAK;QACL,YAAY;QACZ,oBAAoB;QACpB,cAAc;KACjB,CAAA;AACL,CAAC;AA3KD,0CA2KC","sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nimport { audioDeviceManager } from '../AudioDeviceManager'\nimport { AudioDevice } from '../ExpoAudioStream.types'\n\n/**\n * React hook for managing audio input devices\n */\nexport function useAudioDevices() {\n const [devices, setDevices] = useState<AudioDevice[]>([])\n const [currentDevice, setCurrentDevice] = useState<AudioDevice | null>(null)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState<Error | null>(null)\n\n // Load devices on mount\n useEffect(() => {\n let isMounted = true\n\n const loadDevices = async () => {\n try {\n setLoading(true)\n setError(null)\n\n // Load available devices\n const availableDevices =\n await audioDeviceManager.getAvailableDevices()\n if (isMounted) setDevices(availableDevices)\n\n // Get current device\n const device = await audioDeviceManager.getCurrentDevice()\n if (isMounted) setCurrentDevice(device)\n } catch (err) {\n console.error('Failed to load audio devices:', err)\n if (isMounted)\n setError(\n err instanceof Error\n ? err\n : new Error('Failed to load audio devices')\n )\n } finally {\n if (isMounted) setLoading(false)\n }\n }\n\n loadDevices()\n\n // Set up device change listener\n const removeListener = audioDeviceManager.addDeviceChangeListener(\n (updatedDevices: AudioDevice[]) => {\n if (isMounted) {\n setDevices(updatedDevices)\n\n // If our current device is no longer available, update it\n if (\n currentDevice &&\n !updatedDevices.some(\n (d: AudioDevice) => d.id === currentDevice.id\n )\n ) {\n audioDeviceManager\n .getCurrentDevice()\n .then((newDevice: AudioDevice | null) => {\n if (isMounted) setCurrentDevice(newDevice)\n })\n }\n }\n }\n )\n\n return () => {\n isMounted = false\n removeListener()\n }\n }, [])\n\n /**\n * Select a specific audio input device\n * @param deviceId The ID of the device to select\n * @returns Promise resolving to a boolean indicating success\n */\n const selectDevice = useCallback(\n async (deviceId: string): Promise<boolean> => {\n try {\n setLoading(true)\n setError(null)\n\n const success = await audioDeviceManager.selectDevice(deviceId)\n\n if (success) {\n // Get the updated current device after selection\n const device = await audioDeviceManager.getCurrentDevice()\n setCurrentDevice(device)\n }\n\n return success\n } catch (err) {\n console.error('Failed to select audio device:', err)\n setError(\n err instanceof Error\n ? err\n : new Error('Failed to select audio device')\n )\n return false\n } finally {\n setLoading(false)\n }\n },\n []\n )\n\n /**\n * Reset to the default audio input device\n * @returns Promise resolving to a boolean indicating success\n */\n const resetToDefaultDevice = useCallback(async (): Promise<boolean> => {\n try {\n setLoading(true)\n setError(null)\n\n const success = await audioDeviceManager.resetToDefaultDevice()\n\n if (success) {\n // Get the updated current device after reset\n const device = await audioDeviceManager.getCurrentDevice()\n setCurrentDevice(device)\n }\n\n return success\n } catch (err) {\n console.error('Failed to reset to default audio device:', err)\n setError(\n err instanceof Error\n ? err\n : new Error('Failed to reset to default audio device')\n )\n return false\n } finally {\n setLoading(false)\n }\n }, [])\n\n /**\n * Refresh the list of available devices\n */\n const refreshDevices = useCallback(async (): Promise<AudioDevice[]> => {\n try {\n setLoading(true)\n setError(null)\n\n const updatedDevices = await audioDeviceManager.refreshDevices()\n setDevices(updatedDevices)\n\n // Also refresh the current device\n const device = await audioDeviceManager.getCurrentDevice()\n setCurrentDevice(device)\n\n return updatedDevices\n } catch (err) {\n console.error('Failed to refresh audio devices:', err)\n setError(\n err instanceof Error\n ? err\n : new Error('Failed to refresh audio devices')\n )\n return []\n } finally {\n setLoading(false)\n }\n }, [])\n\n return {\n devices,\n currentDevice,\n loading,\n error,\n selectDevice,\n resetToDefaultDevice,\n refreshDevices,\n }\n}\n"]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ // src/index.ts
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.useSharedAudioRecorder = exports.useAudioRecorder = exports.extractMelSpectrogram = exports.extractAudioData = exports.trimAudio = exports.extractPreview = exports.extractAudioAnalysis = exports.extractRawWavAnalysis = exports.ExpoAudioStreamModule = exports.AudioRecorderProvider = exports.useAudioDevices = exports.audioDeviceManager = exports.AudioDeviceManager = void 0;
22
+ const extractAudioAnalysis_1 = require("./AudioAnalysis/extractAudioAnalysis");
23
+ Object.defineProperty(exports, "extractRawWavAnalysis", { enumerable: true, get: function () { return extractAudioAnalysis_1.extractRawWavAnalysis; } });
24
+ Object.defineProperty(exports, "extractAudioAnalysis", { enumerable: true, get: function () { return extractAudioAnalysis_1.extractAudioAnalysis; } });
25
+ const extractAudioData_1 = require("./AudioAnalysis/extractAudioData");
26
+ Object.defineProperty(exports, "extractAudioData", { enumerable: true, get: function () { return extractAudioData_1.extractAudioData; } });
27
+ const extractMelSpectrogram_1 = require("./AudioAnalysis/extractMelSpectrogram");
28
+ Object.defineProperty(exports, "extractMelSpectrogram", { enumerable: true, get: function () { return extractMelSpectrogram_1.extractMelSpectrogram; } });
29
+ const extractPreview_1 = require("./AudioAnalysis/extractPreview");
30
+ Object.defineProperty(exports, "extractPreview", { enumerable: true, get: function () { return extractPreview_1.extractPreview; } });
31
+ const AudioRecorder_provider_1 = require("./AudioRecorder.provider");
32
+ Object.defineProperty(exports, "AudioRecorderProvider", { enumerable: true, get: function () { return AudioRecorder_provider_1.AudioRecorderProvider; } });
33
+ Object.defineProperty(exports, "useSharedAudioRecorder", { enumerable: true, get: function () { return AudioRecorder_provider_1.useSharedAudioRecorder; } });
34
+ const ExpoAudioStreamModule_1 = __importDefault(require("./ExpoAudioStreamModule"));
35
+ exports.ExpoAudioStreamModule = ExpoAudioStreamModule_1.default;
36
+ const trimAudio_1 = require("./trimAudio");
37
+ Object.defineProperty(exports, "trimAudio", { enumerable: true, get: function () { return trimAudio_1.trimAudio; } });
38
+ const useAudioRecorder_1 = require("./useAudioRecorder");
39
+ Object.defineProperty(exports, "useAudioRecorder", { enumerable: true, get: function () { return useAudioRecorder_1.useAudioRecorder; } });
40
+ __exportStar(require("./utils/convertPCMToFloat32"), exports);
41
+ __exportStar(require("./utils/getWavFileInfo"), exports);
42
+ __exportStar(require("./utils/writeWavHeader"), exports);
43
+ // Export AudioDeviceManager
44
+ var AudioDeviceManager_1 = require("./AudioDeviceManager");
45
+ Object.defineProperty(exports, "AudioDeviceManager", { enumerable: true, get: function () { return AudioDeviceManager_1.AudioDeviceManager; } });
46
+ Object.defineProperty(exports, "audioDeviceManager", { enumerable: true, get: function () { return AudioDeviceManager_1.audioDeviceManager; } });
47
+ // Export useAudioDevices hook
48
+ var useAudioDevices_1 = require("./hooks/useAudioDevices");
49
+ Object.defineProperty(exports, "useAudioDevices", { enumerable: true, get: function () { return useAudioDevices_1.useAudioDevices; } });
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,eAAe;;;;;;;;;;;;;;;;;;;;AAEf,+EAG6C;AAyBzC,sGA3BA,4CAAqB,OA2BA;AACrB,qGA3BA,2CAAoB,OA2BA;AAzBxB,uEAAmE;AA4B/D,iGA5BK,mCAAgB,OA4BL;AA3BpB,iFAA6E;AA4BzE,sGA5BK,6CAAqB,OA4BL;AA3BzB,mEAA+D;AAwB3D,+FAxBK,+BAAc,OAwBL;AAvBlB,qEAGiC;AAgB7B,sGAlBA,8CAAqB,OAkBA;AASrB,uGA1BA,+CAAsB,OA0BA;AAxB1B,oFAA2D;AAgBvD,gCAhBG,+BAAqB,CAgBH;AAfzB,2CAAuC;AAmBnC,0FAnBK,qBAAS,OAmBL;AAlBb,yDAAqD;AAqBjD,iGArBK,mCAAgB,OAqBL;AAnBpB,8DAA2C;AAC3C,yDAAsC;AACtC,yDAAsC;AAEtC,4BAA4B;AAC5B,2DAA6E;AAApE,wHAAA,kBAAkB,OAAA;AAAE,wHAAA,kBAAkB,OAAA;AAE/C,8BAA8B;AAC9B,2DAAyD;AAAhD,kHAAA,eAAe,OAAA","sourcesContent":["// src/index.ts\n\nimport {\n extractRawWavAnalysis,\n extractAudioAnalysis,\n} from './AudioAnalysis/extractAudioAnalysis'\nimport { extractAudioData } from './AudioAnalysis/extractAudioData'\nimport { extractMelSpectrogram } from './AudioAnalysis/extractMelSpectrogram'\nimport { extractPreview } from './AudioAnalysis/extractPreview'\nimport {\n AudioRecorderProvider,\n useSharedAudioRecorder,\n} from './AudioRecorder.provider'\nimport ExpoAudioStreamModule from './ExpoAudioStreamModule'\nimport { trimAudio } from './trimAudio'\nimport { useAudioRecorder } from './useAudioRecorder'\n\nexport * from './utils/convertPCMToFloat32'\nexport * from './utils/getWavFileInfo'\nexport * from './utils/writeWavHeader'\n\n// Export AudioDeviceManager\nexport { AudioDeviceManager, audioDeviceManager } from './AudioDeviceManager'\n\n// Export useAudioDevices hook\nexport { useAudioDevices } from './hooks/useAudioDevices'\n\nexport {\n AudioRecorderProvider,\n ExpoAudioStreamModule,\n extractRawWavAnalysis,\n extractAudioAnalysis,\n extractPreview,\n trimAudio,\n extractAudioData,\n extractMelSpectrogram,\n useAudioRecorder,\n useSharedAudioRecorder,\n}\n\nexport type * from './AudioAnalysis/AudioAnalysis.types'\nexport type * from './ExpoAudioStream.types'\n"]}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.trimAudioSimple = exports.trimAudio = void 0;
7
+ const expo_modules_core_1 = require("expo-modules-core");
8
+ const ExpoAudioStreamModule_1 = __importDefault(require("./ExpoAudioStreamModule"));
9
+ // Create a single emitter instance
10
+ const emitter = new expo_modules_core_1.LegacyEventEmitter(ExpoAudioStreamModule_1.default);
11
+ /**
12
+ * Trims an audio file based on the provided options.
13
+ *
14
+ * @experimental This API is experimental and not fully optimized for production use.
15
+ * Performance may vary based on file size and device capabilities.
16
+ * Future versions may include breaking changes.
17
+ *
18
+ * @param options Configuration options for the trimming operation
19
+ * @param progressCallback Optional callback to receive progress updates
20
+ * @returns Promise resolving to the trimmed audio file information, including processing time
21
+ */
22
+ async function trimAudio(options, progressCallback) {
23
+ // Validation
24
+ if (!options.fileUri) {
25
+ throw new Error('fileUri is required');
26
+ }
27
+ const mode = options.mode ?? 'single';
28
+ if (mode === 'single') {
29
+ if (options.startTimeMs === undefined &&
30
+ options.endTimeMs === undefined) {
31
+ throw new Error('At least one of startTimeMs or endTimeMs must be provided in single mode');
32
+ }
33
+ }
34
+ else if (mode === 'keep' || mode === 'remove') {
35
+ if (!options.ranges || options.ranges.length === 0) {
36
+ throw new Error('ranges must be provided and non-empty for keep or remove modes');
37
+ }
38
+ }
39
+ else {
40
+ throw new Error(`Invalid mode: ${mode}. Must be 'single', 'keep', or 'remove'`);
41
+ }
42
+ // Set up progress event listener if callback is provided
43
+ let subscription;
44
+ if (progressCallback) {
45
+ subscription = emitter.addListener('TrimProgress', (event) => {
46
+ progressCallback(event);
47
+ });
48
+ }
49
+ try {
50
+ const result = await ExpoAudioStreamModule_1.default.trimAudio(options);
51
+ return result;
52
+ }
53
+ finally {
54
+ if (subscription) {
55
+ subscription.remove();
56
+ }
57
+ }
58
+ }
59
+ exports.trimAudio = trimAudio;
60
+ /**
61
+ * Simplified version of trimAudio that returns only the URI of the trimmed file.
62
+ *
63
+ * @experimental This API is experimental and not fully optimized for production use.
64
+ * Performance may vary based on file size and device capabilities.
65
+ * Future versions may include breaking changes.
66
+ *
67
+ * @param options Configuration options for the trimming operation
68
+ * @returns Promise resolving to the URI of the trimmed audio file
69
+ */
70
+ async function trimAudioSimple(options) {
71
+ const result = await trimAudio(options);
72
+ return result.uri;
73
+ }
74
+ exports.trimAudioSimple = trimAudioSimple;
75
+ //# sourceMappingURL=trimAudio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trimAudio.js","sourceRoot":"","sources":["../../src/trimAudio.ts"],"names":[],"mappings":";;;;;;AAAA,yDAA8E;AAO9E,oFAA2D;AAE3D,mCAAmC;AACnC,MAAM,OAAO,GAAG,IAAI,sCAAkB,CAAC,+BAAqB,CAAC,CAAA;AAE7D;;;;;;;;;;GAUG;AACI,KAAK,UAAU,SAAS,CAC3B,OAAyB,EACzB,gBAAqD;IAErD,aAAa;IACb,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IAC1C,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAA;IACrC,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpB,IACI,OAAO,CAAC,WAAW,KAAK,SAAS;YACjC,OAAO,CAAC,SAAS,KAAK,SAAS,EACjC,CAAC;YACC,MAAM,IAAI,KAAK,CACX,0EAA0E,CAC7E,CAAA;QACL,CAAC;IACL,CAAC;SAAM,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CACX,gEAAgE,CACnE,CAAA;QACL,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,MAAM,IAAI,KAAK,CACX,iBAAiB,IAAI,yCAAyC,CACjE,CAAA;IACL,CAAC;IAED,yDAAyD;IACzD,IAAI,YAA2C,CAAA;IAC/C,IAAI,gBAAgB,EAAE,CAAC;QACnB,YAAY,GAAG,OAAO,CAAC,WAAW,CAC9B,cAAc,EACd,CAAC,KAAwB,EAAE,EAAE;YACzB,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC,CACJ,CAAA;IACL,CAAC;IAED,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,+BAAqB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAC7D,OAAO,MAAM,CAAA;IACjB,CAAC;YAAS,CAAC;QACP,IAAI,YAAY,EAAE,CAAC;YACf,YAAY,CAAC,MAAM,EAAE,CAAA;QACzB,CAAC;IACL,CAAC;AACL,CAAC;AAjDD,8BAiDC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,eAAe,CACjC,OAAyB;IAEzB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;IACvC,OAAO,MAAM,CAAC,GAAG,CAAA;AACrB,CAAC;AALD,0CAKC","sourcesContent":["import { LegacyEventEmitter, type EventSubscription } from 'expo-modules-core'\n\nimport {\n TrimAudioOptions,\n TrimAudioResult,\n TrimProgressEvent,\n} from './ExpoAudioStream.types'\nimport ExpoAudioStreamModule from './ExpoAudioStreamModule'\n\n// Create a single emitter instance\nconst emitter = new LegacyEventEmitter(ExpoAudioStreamModule)\n\n/**\n * Trims an audio file based on the provided options.\n *\n * @experimental This API is experimental and not fully optimized for production use.\n * Performance may vary based on file size and device capabilities.\n * Future versions may include breaking changes.\n *\n * @param options Configuration options for the trimming operation\n * @param progressCallback Optional callback to receive progress updates\n * @returns Promise resolving to the trimmed audio file information, including processing time\n */\nexport async function trimAudio(\n options: TrimAudioOptions,\n progressCallback?: (event: TrimProgressEvent) => void\n): Promise<TrimAudioResult> {\n // Validation\n if (!options.fileUri) {\n throw new Error('fileUri is required')\n }\n const mode = options.mode ?? 'single'\n if (mode === 'single') {\n if (\n options.startTimeMs === undefined &&\n options.endTimeMs === undefined\n ) {\n throw new Error(\n 'At least one of startTimeMs or endTimeMs must be provided in single mode'\n )\n }\n } else if (mode === 'keep' || mode === 'remove') {\n if (!options.ranges || options.ranges.length === 0) {\n throw new Error(\n 'ranges must be provided and non-empty for keep or remove modes'\n )\n }\n } else {\n throw new Error(\n `Invalid mode: ${mode}. Must be 'single', 'keep', or 'remove'`\n )\n }\n\n // Set up progress event listener if callback is provided\n let subscription: EventSubscription | undefined\n if (progressCallback) {\n subscription = emitter.addListener(\n 'TrimProgress',\n (event: TrimProgressEvent) => {\n progressCallback(event)\n }\n )\n }\n\n try {\n const result = await ExpoAudioStreamModule.trimAudio(options)\n return result\n } finally {\n if (subscription) {\n subscription.remove()\n }\n }\n}\n\n/**\n * Simplified version of trimAudio that returns only the URI of the trimmed file.\n *\n * @experimental This API is experimental and not fully optimized for production use.\n * Performance may vary based on file size and device capabilities.\n * Future versions may include breaking changes.\n *\n * @param options Configuration options for the trimming operation\n * @returns Promise resolving to the URI of the trimmed audio file\n */\nexport async function trimAudioSimple(\n options: TrimAudioOptions\n): Promise<string> {\n const result = await trimAudio(options)\n return result.uri\n}\n"]}