@siteed/expo-audio-stream 2.1.0 → 2.2.0

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 (187) hide show
  1. package/README.md +40 -222
  2. package/build/index.d.ts +11 -15
  3. package/build/index.js +44 -14
  4. package/package.json +49 -110
  5. package/src/index.ts +18 -32
  6. package/CHANGELOG.md +0 -206
  7. package/android/build.gradle +0 -105
  8. package/android/src/main/AndroidManifest.xml +0 -27
  9. package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +0 -166
  10. package/android/src/main/java/net/siteed/audiostream/AudioDataEncoder.kt +0 -9
  11. package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +0 -131
  12. package/android/src/main/java/net/siteed/audiostream/AudioFormatUtils.kt +0 -103
  13. package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +0 -435
  14. package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +0 -2235
  15. package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +0 -1437
  16. package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +0 -152
  17. package/android/src/main/java/net/siteed/audiostream/AudioTrimmer.kt +0 -1099
  18. package/android/src/main/java/net/siteed/audiostream/Constants.kt +0 -21
  19. package/android/src/main/java/net/siteed/audiostream/EventSender.kt +0 -7
  20. package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +0 -739
  21. package/android/src/main/java/net/siteed/audiostream/FFT.kt +0 -99
  22. package/android/src/main/java/net/siteed/audiostream/Features.kt +0 -98
  23. package/android/src/main/java/net/siteed/audiostream/NotificationConfig.kt +0 -70
  24. package/android/src/main/java/net/siteed/audiostream/PermissionUtils.kt +0 -59
  25. package/android/src/main/java/net/siteed/audiostream/RecordingActionReceiver.kt +0 -59
  26. package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +0 -205
  27. package/android/src/main/java/net/siteed/audiostream/WaveformConfig.kt +0 -19
  28. package/android/src/main/java/net/siteed/audiostream/WaveformRenderer.kt +0 -159
  29. package/android/src/main/res/drawable/ic_default_action_icon.xml +0 -16
  30. package/android/src/main/res/drawable/ic_microphone.xml +0 -13
  31. package/android/src/main/res/drawable/ic_pause.xml +0 -10
  32. package/android/src/main/res/drawable/ic_play.xml +0 -10
  33. package/android/src/main/res/drawable/ic_stop.xml +0 -10
  34. package/android/src/main/res/layout/notification_recording.xml +0 -37
  35. package/android/src/main/test/java/net/siteed/audiostream/AudioProcessorTest.kt +0 -56
  36. package/app.plugin.js +0 -1
  37. package/build/AudioAnalysis/AudioAnalysis.types.d.ts +0 -179
  38. package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
  39. package/build/AudioAnalysis/AudioAnalysis.types.js +0 -3
  40. package/build/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
  41. package/build/AudioAnalysis/extractAudioAnalysis.d.ts +0 -68
  42. package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
  43. package/build/AudioAnalysis/extractAudioAnalysis.js +0 -203
  44. package/build/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
  45. package/build/AudioAnalysis/extractAudioData.d.ts +0 -3
  46. package/build/AudioAnalysis/extractAudioData.d.ts.map +0 -1
  47. package/build/AudioAnalysis/extractAudioData.js +0 -5
  48. package/build/AudioAnalysis/extractAudioData.js.map +0 -1
  49. package/build/AudioAnalysis/extractMelSpectrogram.d.ts +0 -14
  50. package/build/AudioAnalysis/extractMelSpectrogram.d.ts.map +0 -1
  51. package/build/AudioAnalysis/extractMelSpectrogram.js +0 -85
  52. package/build/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
  53. package/build/AudioAnalysis/extractPreview.d.ts +0 -11
  54. package/build/AudioAnalysis/extractPreview.d.ts.map +0 -1
  55. package/build/AudioAnalysis/extractPreview.js +0 -25
  56. package/build/AudioAnalysis/extractPreview.js.map +0 -1
  57. package/build/AudioAnalysis/extractWaveform.d.ts +0 -8
  58. package/build/AudioAnalysis/extractWaveform.d.ts.map +0 -1
  59. package/build/AudioAnalysis/extractWaveform.js +0 -11
  60. package/build/AudioAnalysis/extractWaveform.js.map +0 -1
  61. package/build/AudioRecorder.provider.d.ts +0 -11
  62. package/build/AudioRecorder.provider.d.ts.map +0 -1
  63. package/build/AudioRecorder.provider.js +0 -37
  64. package/build/AudioRecorder.provider.js.map +0 -1
  65. package/build/ExpoAudioStream.native.d.ts +0 -3
  66. package/build/ExpoAudioStream.native.d.ts.map +0 -1
  67. package/build/ExpoAudioStream.native.js +0 -6
  68. package/build/ExpoAudioStream.native.js.map +0 -1
  69. package/build/ExpoAudioStream.types.d.ts +0 -532
  70. package/build/ExpoAudioStream.types.d.ts.map +0 -1
  71. package/build/ExpoAudioStream.types.js +0 -2
  72. package/build/ExpoAudioStream.types.js.map +0 -1
  73. package/build/ExpoAudioStream.web.d.ts +0 -59
  74. package/build/ExpoAudioStream.web.d.ts.map +0 -1
  75. package/build/ExpoAudioStream.web.js +0 -285
  76. package/build/ExpoAudioStream.web.js.map +0 -1
  77. package/build/ExpoAudioStreamModule.d.ts +0 -3
  78. package/build/ExpoAudioStreamModule.d.ts.map +0 -1
  79. package/build/ExpoAudioStreamModule.js +0 -693
  80. package/build/ExpoAudioStreamModule.js.map +0 -1
  81. package/build/WebRecorder.web.d.ts +0 -119
  82. package/build/WebRecorder.web.d.ts.map +0 -1
  83. package/build/WebRecorder.web.js +0 -436
  84. package/build/WebRecorder.web.js.map +0 -1
  85. package/build/constants.d.ts +0 -11
  86. package/build/constants.d.ts.map +0 -1
  87. package/build/constants.js +0 -14
  88. package/build/constants.js.map +0 -1
  89. package/build/events.d.ts +0 -26
  90. package/build/events.d.ts.map +0 -1
  91. package/build/events.js +0 -21
  92. package/build/events.js.map +0 -1
  93. package/build/index.d.ts.map +0 -1
  94. package/build/index.js.map +0 -1
  95. package/build/trimAudio.d.ts +0 -25
  96. package/build/trimAudio.d.ts.map +0 -1
  97. package/build/trimAudio.js +0 -67
  98. package/build/trimAudio.js.map +0 -1
  99. package/build/useAudioRecorder.d.ts +0 -21
  100. package/build/useAudioRecorder.d.ts.map +0 -1
  101. package/build/useAudioRecorder.js +0 -427
  102. package/build/useAudioRecorder.js.map +0 -1
  103. package/build/utils/BlobFix.d.ts +0 -9
  104. package/build/utils/BlobFix.d.ts.map +0 -1
  105. package/build/utils/BlobFix.js +0 -498
  106. package/build/utils/BlobFix.js.map +0 -1
  107. package/build/utils/audioProcessing.d.ts +0 -24
  108. package/build/utils/audioProcessing.d.ts.map +0 -1
  109. package/build/utils/audioProcessing.js +0 -133
  110. package/build/utils/audioProcessing.js.map +0 -1
  111. package/build/utils/concatenateBuffers.d.ts +0 -8
  112. package/build/utils/concatenateBuffers.d.ts.map +0 -1
  113. package/build/utils/concatenateBuffers.js +0 -21
  114. package/build/utils/concatenateBuffers.js.map +0 -1
  115. package/build/utils/convertPCMToFloat32.d.ts +0 -13
  116. package/build/utils/convertPCMToFloat32.d.ts.map +0 -1
  117. package/build/utils/convertPCMToFloat32.js +0 -120
  118. package/build/utils/convertPCMToFloat32.js.map +0 -1
  119. package/build/utils/encodingToBitDepth.d.ts +0 -5
  120. package/build/utils/encodingToBitDepth.d.ts.map +0 -1
  121. package/build/utils/encodingToBitDepth.js +0 -13
  122. package/build/utils/encodingToBitDepth.js.map +0 -1
  123. package/build/utils/getWavFileInfo.d.ts +0 -26
  124. package/build/utils/getWavFileInfo.d.ts.map +0 -1
  125. package/build/utils/getWavFileInfo.js +0 -92
  126. package/build/utils/getWavFileInfo.js.map +0 -1
  127. package/build/utils/writeWavHeader.d.ts +0 -49
  128. package/build/utils/writeWavHeader.d.ts.map +0 -1
  129. package/build/utils/writeWavHeader.js +0 -91
  130. package/build/utils/writeWavHeader.js.map +0 -1
  131. package/build/workers/InlineFeaturesExtractor.web.d.ts +0 -2
  132. package/build/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
  133. package/build/workers/InlineFeaturesExtractor.web.js +0 -828
  134. package/build/workers/InlineFeaturesExtractor.web.js.map +0 -1
  135. package/build/workers/inlineAudioWebWorker.web.d.ts +0 -2
  136. package/build/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
  137. package/build/workers/inlineAudioWebWorker.web.js +0 -157
  138. package/build/workers/inlineAudioWebWorker.web.js.map +0 -1
  139. package/expo-module.config.json +0 -9
  140. package/ios/AudioAnalysisData.swift +0 -74
  141. package/ios/AudioNotificationManager.swift +0 -135
  142. package/ios/AudioProcessingHelpers.swift +0 -743
  143. package/ios/AudioProcessor.swift +0 -1313
  144. package/ios/AudioStreamError.swift +0 -7
  145. package/ios/AudioStreamManager.swift +0 -1708
  146. package/ios/AudioStreamManagerDelegate.swift +0 -16
  147. package/ios/DataPoint.swift +0 -54
  148. package/ios/DecodingConfig.swift +0 -47
  149. package/ios/ExpoAudioStream.podspec +0 -27
  150. package/ios/ExpoAudioStreamModule.swift +0 -805
  151. package/ios/FFT.swift +0 -62
  152. package/ios/Features.swift +0 -95
  153. package/ios/Logger.swift +0 -7
  154. package/ios/NotificationExtension.swift +0 -15
  155. package/ios/RecordingResult.swift +0 -22
  156. package/ios/RecordingSettings.swift +0 -265
  157. package/ios/WaveformExtractor.swift +0 -105
  158. package/plugin/build/index.d.ts +0 -21
  159. package/plugin/build/index.js +0 -191
  160. package/plugin/src/index.ts +0 -278
  161. package/plugin/tsconfig.json +0 -10
  162. package/plugin/tsconfig.tsbuildinfo +0 -1
  163. package/src/AudioAnalysis/AudioAnalysis.types.ts +0 -202
  164. package/src/AudioAnalysis/extractAudioAnalysis.ts +0 -333
  165. package/src/AudioAnalysis/extractAudioData.ts +0 -6
  166. package/src/AudioAnalysis/extractMelSpectrogram.ts +0 -144
  167. package/src/AudioAnalysis/extractPreview.ts +0 -34
  168. package/src/AudioAnalysis/extractWaveform.ts +0 -22
  169. package/src/AudioRecorder.provider.tsx +0 -54
  170. package/src/ExpoAudioStream.native.ts +0 -6
  171. package/src/ExpoAudioStream.types.ts +0 -641
  172. package/src/ExpoAudioStream.web.ts +0 -359
  173. package/src/ExpoAudioStreamModule.ts +0 -967
  174. package/src/WebRecorder.web.ts +0 -580
  175. package/src/constants.ts +0 -18
  176. package/src/events.ts +0 -60
  177. package/src/trimAudio.ts +0 -90
  178. package/src/useAudioRecorder.tsx +0 -620
  179. package/src/utils/BlobFix.ts +0 -559
  180. package/src/utils/audioProcessing.ts +0 -205
  181. package/src/utils/concatenateBuffers.ts +0 -24
  182. package/src/utils/convertPCMToFloat32.ts +0 -170
  183. package/src/utils/encodingToBitDepth.ts +0 -18
  184. package/src/utils/getWavFileInfo.ts +0 -132
  185. package/src/utils/writeWavHeader.ts +0 -114
  186. package/src/workers/InlineFeaturesExtractor.web.tsx +0 -827
  187. package/src/workers/inlineAudioWebWorker.web.tsx +0 -156
@@ -1,203 +0,0 @@
1
- // packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts
2
- /**
3
- * This module provides functions for extracting and analyzing audio data.
4
- * - `extractAudioAnalysis`: For detailed analysis with customizable ranges and decoding options.
5
- * - `extractWavAudioAnalysis`: For analyzing WAV files without decoding, preserving original PCM values.
6
- * - `extractPreview`: For generating quick previews of audio waveforms, optimized for UI rendering.
7
- */
8
- import crc32 from 'crc-32';
9
- import ExpoAudioStreamModule from '../ExpoAudioStreamModule';
10
- import { isWeb } from '../constants';
11
- import { processAudioBuffer } from '../utils/audioProcessing';
12
- import { convertPCMToFloat32 } from '../utils/convertPCMToFloat32';
13
- import { getWavFileInfo } from '../utils/getWavFileInfo';
14
- import { InlineFeaturesExtractor } from '../workers/InlineFeaturesExtractor.web';
15
- function calculateCRC32ForDataPoint(data) {
16
- // Convert float array to byte array for CRC32
17
- const byteArray = new Uint8Array(data.length * 4);
18
- const dataView = new DataView(byteArray.buffer);
19
- for (let i = 0; i < data.length; i++) {
20
- dataView.setFloat32(i * 4, data[i], true);
21
- }
22
- return crc32.buf(byteArray);
23
- }
24
- /**
25
- * Extracts detailed audio analysis from the specified audio file or buffer.
26
- * Supports either time-based or byte-based ranges for flexibility in analysis.
27
- *
28
- * @param props - The options for extraction, including file URI, ranges, and decoding settings.
29
- * @returns A promise that resolves to the audio analysis data.
30
- * @throws {Error} If both time and byte ranges are provided or if required parameters are missing.
31
- */
32
- export async function extractAudioAnalysis(props) {
33
- const { fileUri, arrayBuffer, decodingOptions, logger, segmentDurationMs = 100, features, } = props;
34
- if (isWeb) {
35
- try {
36
- // Create AudioContext here
37
- const audioContext = new (window.AudioContext ||
38
- window.webkitAudioContext)({
39
- sampleRate: decodingOptions?.targetSampleRate ?? 16000,
40
- });
41
- try {
42
- const processedBuffer = await processAudioBuffer({
43
- arrayBuffer,
44
- fileUri,
45
- targetSampleRate: decodingOptions?.targetSampleRate ?? 16000,
46
- targetChannels: decodingOptions?.targetChannels ?? 1,
47
- normalizeAudio: decodingOptions?.normalizeAudio ?? false,
48
- startTimeMs: 'startTimeMs' in props ? props.startTimeMs : undefined,
49
- endTimeMs: 'endTimeMs' in props ? props.endTimeMs : undefined,
50
- position: 'position' in props ? props.position : undefined,
51
- length: 'length' in props ? props.length : undefined,
52
- audioContext, // Pass the context we created
53
- logger,
54
- });
55
- const channelData = processedBuffer.buffer.getChannelData(0);
56
- // Create and initialize the worker
57
- const blob = new Blob([InlineFeaturesExtractor], {
58
- type: 'application/javascript',
59
- });
60
- const workerUrl = URL.createObjectURL(blob);
61
- const worker = new Worker(workerUrl);
62
- return new Promise((resolve, reject) => {
63
- worker.onmessage = (event) => {
64
- if (event.data.error) {
65
- reject(new Error(event.data.error));
66
- return;
67
- }
68
- const result = event.data.result;
69
- // Calculate CRC32 after worker completes if requested
70
- if (features?.crc32) {
71
- const samplesPerSegment = Math.floor((processedBuffer.sampleRate *
72
- segmentDurationMs) /
73
- 1000);
74
- result.dataPoints = result.dataPoints.map((point, index) => {
75
- const startSample = index * samplesPerSegment;
76
- const segmentData = channelData.slice(startSample, startSample + samplesPerSegment);
77
- return {
78
- ...point,
79
- features: {
80
- ...point.features,
81
- crc32: calculateCRC32ForDataPoint(segmentData),
82
- },
83
- };
84
- });
85
- }
86
- URL.revokeObjectURL(workerUrl);
87
- worker.terminate();
88
- resolve(result);
89
- };
90
- worker.onerror = (error) => {
91
- URL.revokeObjectURL(workerUrl);
92
- worker.terminate();
93
- reject(error);
94
- };
95
- worker.postMessage({
96
- channelData,
97
- sampleRate: processedBuffer.sampleRate,
98
- segmentDurationMs,
99
- bitDepth: decodingOptions?.targetBitDepth ?? 32,
100
- numberOfChannels: processedBuffer.channels,
101
- // enableLogging: !!logger,
102
- features,
103
- });
104
- });
105
- }
106
- finally {
107
- await audioContext.close();
108
- }
109
- }
110
- catch (error) {
111
- logger?.error('Failed to process audio:', error);
112
- throw error;
113
- }
114
- }
115
- else {
116
- return await ExpoAudioStreamModule.extractAudioAnalysis(props);
117
- }
118
- }
119
- /**
120
- * Analyzes WAV files without decoding, preserving original PCM values.
121
- * Use this function when you need to ensure the analysis matches other software by avoiding any transformations.
122
- *
123
- * @param props - The options for WAV analysis, including file URI and range.
124
- * @returns A promise that resolves to the audio analysis data.
125
- */
126
- export const extractRawWavAnalysis = async ({ fileUri, segmentDurationMs = 100, // Default to 100ms
127
- arrayBuffer, bitDepth, durationMs, sampleRate, numberOfChannels, features, logger, position = 0, length, }) => {
128
- if (isWeb) {
129
- if (!arrayBuffer && !fileUri) {
130
- throw new Error('Either arrayBuffer or fileUri must be provided');
131
- }
132
- if (!arrayBuffer) {
133
- logger?.log(`fetching fileUri`, fileUri);
134
- const response = await fetch(fileUri);
135
- if (!response.ok) {
136
- throw new Error(`Failed to fetch fileUri: ${response.statusText}`);
137
- }
138
- arrayBuffer = await response.arrayBuffer();
139
- logger?.log(`fetched fileUri`, arrayBuffer.byteLength, arrayBuffer);
140
- }
141
- // Create a new copy of the ArrayBuffer to avoid detachment issues
142
- const bufferCopy = arrayBuffer.slice(0);
143
- logger?.log(`extractAudioAnalysis bitDepth=${bitDepth} len=${bufferCopy.byteLength}`, bufferCopy.slice(0, 100));
144
- let actualBitDepth = bitDepth;
145
- if (!actualBitDepth) {
146
- logger?.log(`extractAudioAnalysis bitDepth not provided -- getting wav file info`);
147
- const fileInfo = await getWavFileInfo(bufferCopy);
148
- actualBitDepth = fileInfo.bitDepth;
149
- }
150
- logger?.log(`extractAudioAnalysis actualBitDepth=${actualBitDepth}`);
151
- const { pcmValues: channelData, min, max, } = await convertPCMToFloat32({
152
- buffer: arrayBuffer,
153
- bitDepth: actualBitDepth,
154
- });
155
- logger?.log(`extractAudioAnalysis convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`);
156
- // Apply position and length constraints to channelData if specified
157
- const startIndex = position;
158
- const endIndex = length ? startIndex + length : channelData.length;
159
- const constrainedChannelData = channelData.slice(startIndex, endIndex);
160
- return new Promise((resolve, reject) => {
161
- const blob = new Blob([InlineFeaturesExtractor], {
162
- type: 'application/javascript',
163
- });
164
- const url = URL.createObjectURL(blob);
165
- const worker = new Worker(url);
166
- worker.onmessage = (event) => {
167
- resolve(event.data.result);
168
- };
169
- worker.onerror = (error) => {
170
- reject(error);
171
- };
172
- worker.postMessage({
173
- command: 'process',
174
- channelData: constrainedChannelData,
175
- sampleRate,
176
- segmentDurationMs,
177
- logger,
178
- bitDepth,
179
- fullAudioDurationMs: durationMs,
180
- numberOfChannels,
181
- });
182
- });
183
- }
184
- else {
185
- if (!fileUri) {
186
- throw new Error('fileUri is required');
187
- }
188
- logger?.log(`extractAudioAnalysis`, {
189
- fileUri,
190
- segmentDurationMs,
191
- });
192
- const res = await ExpoAudioStreamModule.extractAudioAnalysis({
193
- fileUri,
194
- segmentDurationMs,
195
- features,
196
- position,
197
- length,
198
- });
199
- logger?.log(`extractAudioAnalysis`, res);
200
- return res;
201
- }
202
- };
203
- //# sourceMappingURL=extractAudioAnalysis.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractAudioAnalysis.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioAnalysis.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE;;;;;GA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AI,CAAC,CAAC,uBAAuB,CAAC,EAAE;gBAC7C,IAAI,EAAE,wBAAwB;aACjC,CAAC,CAAA;YACF,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;YACrC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;YAE9B,MAAM,CAAC,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE;gBACzB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC9B,CAAC,CAAA;YAED,MAAM,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE;gBACvB,MAAM,CAAC,KAAK,CAAC,CAAA;YACjB,CAAC,CAAA;YAED,MAAM,CAAC,WAAW,CAAC;gBACf,OAAO,EAAE,SAAS;gBAClB,WAAW,EAAE,sBAAsB;gBACnC,UAAU;gBACV,iBAAiB;gBACjB,MAAM;gBACN,QAAQ;gBACR,mBAAmB,EAAE,UAAU;gBAC/B,gBAAgB;aACnB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QAC1C,CAAC;QACD,MAAM,EAAE,GAAG,CAAC,sBAAsB,EAAE;YAChC,OAAO;YACP,iBAAiB;SACpB,CAAC,CAAA;QACF,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,OAAO;YACP,iBAAiB;YACjB,QAAQ;YACR,QAAQ;YACR,MAAM;SACT,CAAC,CAAA;QACF,MAAM,EAAE,GAAG,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;QACxC,OAAO,GAAG,CAAA;IACd,CAAC;AACL,CAAC,CAAA","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts\n/**\n * This module provides functions for extracting and analyzing audio data.\n * - `extractAudioAnalysis`: For detailed analysis with customizable ranges and decoding options.\n * - `extractWavAudioAnalysis`: For analyzing WAV files without decoding, preserving original PCM values.\n * - `extractPreview`: For generating quick previews of audio waveforms, optimized for UI rendering.\n */\nimport crc32 from 'crc-32'\n\nimport { ConsoleLike } from '../ExpoAudioStream.types'\nimport ExpoAudioStreamModule from '../ExpoAudioStreamModule'\nimport { isWeb } from '../constants'\nimport {\n AudioAnalysis,\n AudioFeaturesOptions,\n DataPoint,\n DecodingConfig,\n} from './AudioAnalysis.types'\nimport { processAudioBuffer } from '../utils/audioProcessing'\nimport { convertPCMToFloat32 } from '../utils/convertPCMToFloat32'\nimport { getWavFileInfo, WavFileInfo } from '../utils/getWavFileInfo'\nimport { InlineFeaturesExtractor } from '../workers/InlineFeaturesExtractor.web'\n\nfunction calculateCRC32ForDataPoint(data: Float32Array): number {\n // Convert float array to byte array for CRC32\n const byteArray = new Uint8Array(data.length * 4)\n const dataView = new DataView(byteArray.buffer)\n\n for (let i = 0; i < data.length; i++) {\n dataView.setFloat32(i * 4, data[i], true)\n }\n\n return crc32.buf(byteArray)\n}\n\nexport interface ExtractWavAudioAnalysisProps {\n fileUri?: string // should provide either fileUri or arrayBuffer\n wavMetadata?: WavFileInfo\n arrayBuffer?: ArrayBuffer\n bitDepth?: number\n durationMs?: number\n sampleRate?: number\n numberOfChannels?: number\n position?: number // Optional number of bytes to skip. Default is 0\n length?: number // Optional number of bytes to read.\n segmentDurationMs?: number // Optional number of points per second. Use to reduce the number of points and compute the number of datapoints to return.\n features?: AudioFeaturesOptions\n featuresExtratorUrl?: string\n logger?: ConsoleLike\n decodingOptions?: DecodingConfig\n}\n\n// Define base options interface with common properties\ninterface BaseExtractOptions {\n fileUri?: string\n arrayBuffer?: ArrayBuffer\n /**\n * Duration of each analysis segment in milliseconds. Defaults to 100ms if not specified.\n */\n segmentDurationMs?: number\n features?: AudioFeaturesOptions\n decodingOptions?: DecodingConfig\n logger?: ConsoleLike\n}\n\n// Time-based range options\ninterface TimeRangeOptions extends BaseExtractOptions {\n startTimeMs?: number\n endTimeMs?: number\n position?: never\n length?: never\n}\n\n// Byte-based range options\ninterface ByteRangeOptions extends BaseExtractOptions {\n position?: number\n length?: number\n startTimeMs?: never\n endTimeMs?: never\n}\n\n/**\n * Options for extracting audio analysis.\n * - For time-based analysis, provide `startTimeMs` and `endTimeMs`.\n * - For byte-based analysis, provide `position` and `length`.\n * - Do not mix time and byte ranges.\n */\nexport type ExtractAudioAnalysisProps = TimeRangeOptions | ByteRangeOptions\n\n/**\n * Extracts detailed audio analysis from the specified audio file or buffer.\n * Supports either time-based or byte-based ranges for flexibility in analysis.\n *\n * @param props - The options for extraction, including file URI, ranges, and decoding settings.\n * @returns A promise that resolves to the audio analysis data.\n * @throws {Error} If both time and byte ranges are provided or if required parameters are missing.\n */\nexport async function extractAudioAnalysis(\n props: ExtractAudioAnalysisProps\n): Promise<AudioAnalysis> {\n const {\n fileUri,\n arrayBuffer,\n decodingOptions,\n logger,\n segmentDurationMs = 100,\n features,\n } = props\n\n if (isWeb) {\n try {\n // Create AudioContext here\n const audioContext = new (window.AudioContext ||\n (window as any).webkitAudioContext)({\n sampleRate: decodingOptions?.targetSampleRate ?? 16000,\n })\n\n try {\n const processedBuffer = await processAudioBuffer({\n arrayBuffer,\n fileUri,\n targetSampleRate:\n decodingOptions?.targetSampleRate ?? 16000,\n targetChannels: decodingOptions?.targetChannels ?? 1,\n normalizeAudio: decodingOptions?.normalizeAudio ?? false,\n startTimeMs:\n 'startTimeMs' in props ? props.startTimeMs : undefined,\n endTimeMs:\n 'endTimeMs' in props ? props.endTimeMs : undefined,\n position: 'position' in props ? props.position : undefined,\n length: 'length' in props ? props.length : undefined,\n audioContext, // Pass the context we created\n logger,\n })\n\n const channelData = processedBuffer.buffer.getChannelData(0)\n\n // Create and initialize the worker\n const blob = new Blob([InlineFeaturesExtractor], {\n type: 'application/javascript',\n })\n const workerUrl = URL.createObjectURL(blob)\n const worker = new Worker(workerUrl)\n\n return new Promise((resolve, reject) => {\n worker.onmessage = (event) => {\n if (event.data.error) {\n reject(new Error(event.data.error))\n return\n }\n\n const result: AudioAnalysis = event.data.result\n // Calculate CRC32 after worker completes if requested\n if (features?.crc32) {\n const samplesPerSegment = Math.floor(\n (processedBuffer.sampleRate *\n segmentDurationMs) /\n 1000\n )\n\n result.dataPoints = result.dataPoints.map(\n (point: DataPoint, index: number) => {\n const startSample =\n index * samplesPerSegment\n const segmentData = channelData.slice(\n startSample,\n startSample + samplesPerSegment\n )\n\n return {\n ...point,\n features: {\n ...point.features,\n crc32: calculateCRC32ForDataPoint(\n segmentData\n ),\n },\n }\n }\n )\n }\n\n URL.revokeObjectURL(workerUrl)\n worker.terminate()\n resolve(result)\n }\n\n worker.onerror = (error) => {\n URL.revokeObjectURL(workerUrl)\n worker.terminate()\n reject(error)\n }\n\n worker.postMessage({\n channelData,\n sampleRate: processedBuffer.sampleRate,\n segmentDurationMs,\n bitDepth: decodingOptions?.targetBitDepth ?? 32,\n numberOfChannels: processedBuffer.channels,\n // enableLogging: !!logger,\n features,\n })\n })\n } finally {\n await audioContext.close()\n }\n } catch (error) {\n logger?.error('Failed to process audio:', error)\n throw error\n }\n } else {\n return await ExpoAudioStreamModule.extractAudioAnalysis(props)\n }\n}\n\n/**\n * Analyzes WAV files without decoding, preserving original PCM values.\n * Use this function when you need to ensure the analysis matches other software by avoiding any transformations.\n *\n * @param props - The options for WAV analysis, including file URI and range.\n * @returns A promise that resolves to the audio analysis data.\n */\nexport const extractRawWavAnalysis = async ({\n fileUri,\n segmentDurationMs = 100, // Default to 100ms\n arrayBuffer,\n bitDepth,\n durationMs,\n sampleRate,\n numberOfChannels,\n features,\n logger,\n position = 0,\n length,\n}: ExtractWavAudioAnalysisProps): Promise<AudioAnalysis> => {\n if (isWeb) {\n if (!arrayBuffer && !fileUri) {\n throw new Error('Either arrayBuffer or fileUri must be provided')\n }\n\n if (!arrayBuffer) {\n logger?.log(`fetching fileUri`, fileUri)\n const response = await fetch(fileUri!)\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch fileUri: ${response.statusText}`\n )\n }\n\n arrayBuffer = await response.arrayBuffer()\n logger?.log(`fetched fileUri`, arrayBuffer.byteLength, arrayBuffer)\n }\n\n // Create a new copy of the ArrayBuffer to avoid detachment issues\n const bufferCopy = arrayBuffer.slice(0)\n logger?.log(\n `extractAudioAnalysis bitDepth=${bitDepth} len=${bufferCopy.byteLength}`,\n bufferCopy.slice(0, 100)\n )\n\n let actualBitDepth = bitDepth\n if (!actualBitDepth) {\n logger?.log(\n `extractAudioAnalysis bitDepth not provided -- getting wav file info`\n )\n const fileInfo = await getWavFileInfo(bufferCopy)\n actualBitDepth = fileInfo.bitDepth\n }\n logger?.log(`extractAudioAnalysis actualBitDepth=${actualBitDepth}`)\n\n const {\n pcmValues: channelData,\n min,\n max,\n } = await convertPCMToFloat32({\n buffer: arrayBuffer,\n bitDepth: actualBitDepth,\n })\n logger?.log(\n `extractAudioAnalysis convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`\n )\n\n // Apply position and length constraints to channelData if specified\n const startIndex = position\n const endIndex = length ? startIndex + length : channelData.length\n const constrainedChannelData = channelData.slice(startIndex, endIndex)\n\n return new Promise((resolve, reject) => {\n const blob = new Blob([InlineFeaturesExtractor], {\n type: 'application/javascript',\n })\n const url = URL.createObjectURL(blob)\n const worker = new Worker(url)\n\n worker.onmessage = (event) => {\n resolve(event.data.result)\n }\n\n worker.onerror = (error) => {\n reject(error)\n }\n\n worker.postMessage({\n command: 'process',\n channelData: constrainedChannelData,\n sampleRate,\n segmentDurationMs,\n logger,\n bitDepth,\n fullAudioDurationMs: durationMs,\n numberOfChannels,\n })\n })\n } else {\n if (!fileUri) {\n throw new Error('fileUri is required')\n }\n logger?.log(`extractAudioAnalysis`, {\n fileUri,\n segmentDurationMs,\n })\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n segmentDurationMs,\n features,\n position,\n length,\n })\n logger?.log(`extractAudioAnalysis`, res)\n return res\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- import { ExtractAudioDataOptions } from '../ExpoAudioStream.types';
2
- export declare const extractAudioData: (props: ExtractAudioDataOptions) => Promise<any>;
3
- //# sourceMappingURL=extractAudioData.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractAudioData.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAGlE,eAAO,MAAM,gBAAgB,UAAiB,uBAAuB,iBAEpE,CAAA"}
@@ -1,5 +0,0 @@
1
- import ExpoAudioStreamModule from '../ExpoAudioStreamModule';
2
- export const extractAudioData = async (props) => {
3
- return await ExpoAudioStreamModule.extractAudioData(props);
4
- };
5
- //# sourceMappingURL=extractAudioData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractAudioData.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioData.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,0BAA0B,CAAA;AAE5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,KAA8B,EAAE,EAAE;IACrE,OAAO,MAAM,qBAAqB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;AAC9D,CAAC,CAAA","sourcesContent":["import { ExtractAudioDataOptions } from '../ExpoAudioStream.types'\nimport ExpoAudioStreamModule from '../ExpoAudioStreamModule'\n\nexport const extractAudioData = async (props: ExtractAudioDataOptions) => {\n return await ExpoAudioStreamModule.extractAudioData(props)\n}\n"]}
@@ -1,14 +0,0 @@
1
- /**
2
- * @experimental This feature is experimental and currently only available on Android.
3
- * The API may change in future versions. The web implementation is a placeholder.
4
- */
5
- import { ExtractMelSpectrogramOptions, MelSpectrogram } from './AudioAnalysis.types';
6
- /**
7
- * Extracts a mel spectrogram from audio data
8
- *
9
- * @experimental This feature is experimental and currently only available on Android.
10
- * The iOS implementation will throw an "UNSUPPORTED_PLATFORM" error.
11
- * The web implementation is a placeholder that returns dummy data.
12
- */
13
- export declare function extractMelSpectrogram(options: ExtractMelSpectrogramOptions): Promise<MelSpectrogram>;
14
- //# sourceMappingURL=extractMelSpectrogram.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractMelSpectrogram.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractMelSpectrogram.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,4BAA4B,EAC5B,cAAc,EACjB,MAAM,uBAAuB,CAAA;AAM9B;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACvC,OAAO,EAAE,4BAA4B,GACtC,OAAO,CAAC,cAAc,CAAC,CA8EzB"}
@@ -1,85 +0,0 @@
1
- /**
2
- * @experimental This feature is experimental and currently only available on Android.
3
- * The API may change in future versions. The web implementation is a placeholder.
4
- */
5
- import { ExpoAudioStreamModule } from '..';
6
- import { isWeb } from '../constants';
7
- import { processAudioBuffer, } from '../utils/audioProcessing';
8
- /**
9
- * Extracts a mel spectrogram from audio data
10
- *
11
- * @experimental This feature is experimental and currently only available on Android.
12
- * The iOS implementation will throw an "UNSUPPORTED_PLATFORM" error.
13
- * The web implementation is a placeholder that returns dummy data.
14
- */
15
- export async function extractMelSpectrogram(options) {
16
- const { fileUri, arrayBuffer, windowSizeMs, hopLengthMs, nMels, fMin = 0, fMax, windowType = 'hann', normalize = false, logScale = true, decodingOptions, startTimeMs, endTimeMs, logger, } = options;
17
- if (isWeb) {
18
- // Create audio context
19
- const audioContext = new (window.AudioContext ||
20
- window.webkitAudioContext)();
21
- try {
22
- // Process audio data using the existing utility
23
- const processedAudio = await processAudioBuffer({
24
- arrayBuffer,
25
- fileUri,
26
- targetSampleRate: decodingOptions?.targetSampleRate || 16000,
27
- targetChannels: decodingOptions?.targetChannels || 1,
28
- normalizeAudio: decodingOptions?.normalizeAudio ?? false,
29
- startTimeMs,
30
- endTimeMs,
31
- audioContext,
32
- logger: options.logger,
33
- });
34
- // Calculate window and hop size in samples
35
- const sampleRate = processedAudio.sampleRate;
36
- const windowSize = Math.floor((windowSizeMs * sampleRate) / 1000);
37
- const hopLength = Math.floor((hopLengthMs * sampleRate) / 1000);
38
- const maxFreq = fMax || sampleRate / 2;
39
- // Extract the mel spectrogram from the processed audio
40
- const spectrogram = computeMelSpectrogram(processedAudio.channelData, sampleRate, nMels, windowSize, hopLength, fMin, maxFreq, windowType, normalize, logScale);
41
- const timeSteps = spectrogram.length;
42
- return {
43
- spectrogram,
44
- sampleRate,
45
- nMels,
46
- timeSteps,
47
- durationMs: processedAudio.durationMs,
48
- };
49
- }
50
- catch (error) {
51
- logger?.error('Error extracting mel spectrogram:', error);
52
- throw error;
53
- }
54
- finally {
55
- // Close the audio context
56
- await audioContext.close();
57
- }
58
- }
59
- return ExpoAudioStreamModule.extractMelSpectrogram(options);
60
- }
61
- /**
62
- * Computes a mel spectrogram from audio data
63
- *
64
- * @experimental This is a placeholder implementation that returns dummy data.
65
- * The actual implementation will be added in a future version.
66
- */
67
- function computeMelSpectrogram(audioData, sampleRate, nMels, windowSize, hopLength, fMin, fMax, windowType, normalize, logScale) {
68
- // Placeholder for the actual implementation
69
- // This would include:
70
- // 1. Windowing the audio data using the specified window type
71
- // 2. Computing the STFT (Short-Time Fourier Transform)
72
- // 3. Converting to power spectrogram
73
- // 4. Applying mel filterbanks
74
- // 5. Taking the logarithm if logScale is true
75
- // 6. Normalizing if normalize is true
76
- // For now, return a dummy implementation
77
- const numFrames = Math.floor((audioData.length - windowSize) / hopLength) + 1;
78
- const spectrogram = [];
79
- // Create dummy mel spectrogram data
80
- for (let i = 0; i < numFrames; i++) {
81
- spectrogram.push(Array(nMels).fill(0));
82
- }
83
- return spectrogram;
84
- }
85
- //# sourceMappingURL=extractMelSpectrogram.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractMelSpectrogram.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractMelSpectrogram.ts"],"names":[],"mapp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E,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1C,CAAC;IAED,OAAO,WAAW,CAAA;AACtB,CAAC","sourcesContent":["/**\n * @experimental This feature is experimental and currently only available on Android.\n * The API may change in future versions. The web implementation is a placeholder.\n */\n\nimport { ExpoAudioStreamModule } from '..'\nimport { isWeb } from '../constants'\nimport {\n ExtractMelSpectrogramOptions,\n MelSpectrogram,\n} from './AudioAnalysis.types'\nimport {\n processAudioBuffer,\n ProcessedAudioData,\n} from '../utils/audioProcessing'\n\n/**\n * Extracts a mel spectrogram from audio data\n * \n * @experimental This feature is experimental and currently only available on Android.\n * The iOS implementation will throw an \"UNSUPPORTED_PLATFORM\" error.\n * The web implementation is a placeholder that returns dummy data.\n */\nexport async function extractMelSpectrogram(\n options: ExtractMelSpectrogramOptions\n): Promise<MelSpectrogram> {\n const {\n fileUri,\n arrayBuffer,\n windowSizeMs,\n hopLengthMs,\n nMels,\n fMin = 0,\n fMax,\n windowType = 'hann',\n normalize = false,\n logScale = true,\n decodingOptions,\n startTimeMs,\n endTimeMs,\n logger,\n } = options\n\n if (isWeb) {\n // Create audio context\n const audioContext = new (window.AudioContext ||\n (window as any).webkitAudioContext)()\n\n try {\n // Process audio data using the existing utility\n const processedAudio: ProcessedAudioData = await processAudioBuffer(\n {\n arrayBuffer,\n fileUri,\n targetSampleRate:\n decodingOptions?.targetSampleRate || 16000,\n targetChannels: decodingOptions?.targetChannels || 1,\n normalizeAudio: decodingOptions?.normalizeAudio ?? false,\n startTimeMs,\n endTimeMs,\n audioContext,\n logger: options.logger,\n }\n )\n\n // Calculate window and hop size in samples\n const sampleRate = processedAudio.sampleRate\n const windowSize = Math.floor((windowSizeMs * sampleRate) / 1000)\n const hopLength = Math.floor((hopLengthMs * sampleRate) / 1000)\n const maxFreq = fMax || sampleRate / 2\n\n // Extract the mel spectrogram from the processed audio\n const spectrogram = computeMelSpectrogram(\n processedAudio.channelData,\n sampleRate,\n nMels,\n windowSize,\n hopLength,\n fMin,\n maxFreq,\n windowType,\n normalize,\n logScale\n )\n\n const timeSteps = spectrogram.length\n\n return {\n spectrogram,\n sampleRate,\n nMels,\n timeSteps,\n durationMs: processedAudio.durationMs,\n }\n } catch (error) {\n logger?.error('Error extracting mel spectrogram:', error)\n throw error\n } finally {\n // Close the audio context\n await audioContext.close()\n }\n }\n return ExpoAudioStreamModule.extractMelSpectrogram(options)\n}\n\n/**\n * Computes a mel spectrogram from audio data\n * \n * @experimental This is a placeholder implementation that returns dummy data.\n * The actual implementation will be added in a future version.\n */\nfunction computeMelSpectrogram(\n audioData: Float32Array,\n sampleRate: number,\n nMels: number,\n windowSize: number,\n hopLength: number,\n fMin: number,\n fMax: number,\n windowType: 'hann' | 'hamming',\n normalize: boolean,\n logScale: boolean\n): number[][] {\n // Placeholder for the actual implementation\n // This would include:\n // 1. Windowing the audio data using the specified window type\n // 2. Computing the STFT (Short-Time Fourier Transform)\n // 3. Converting to power spectrogram\n // 4. Applying mel filterbanks\n // 5. Taking the logarithm if logScale is true\n // 6. Normalizing if normalize is true\n\n // For now, return a dummy implementation\n const numFrames =\n Math.floor((audioData.length - windowSize) / hopLength) + 1\n const spectrogram: number[][] = []\n\n // Create dummy mel spectrogram data\n for (let i = 0; i < numFrames; i++) {\n spectrogram.push(Array(nMels).fill(0))\n }\n\n return spectrogram\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { PreviewOptions, AudioAnalysis } from './AudioAnalysis.types';
2
- /**
3
- * Generates a simplified preview of the audio waveform for quick visualization.
4
- * Ideal for UI rendering with a specified number of points.
5
- *
6
- * @param options - The options for the preview, including file URI and time range.
7
- * @returns A promise that resolves to the audio preview data.
8
- */
9
- export declare function extractPreview({ fileUri, numberOfPoints, startTimeMs, endTimeMs, // First 30 seconds
10
- decodingOptions, logger, }: PreviewOptions): Promise<AudioAnalysis>;
11
- //# sourceMappingURL=extractPreview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractPreview.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractPreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAGrE;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,EACjC,OAAO,EACP,cAAoB,EACpB,WAAe,EACf,SAAiB,EAAE,mBAAmB;AACtC,eAAe,EACf,MAAM,GACT,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAgBzC"}
@@ -1,25 +0,0 @@
1
- import { extractAudioAnalysis } from './extractAudioAnalysis';
2
- /**
3
- * Generates a simplified preview of the audio waveform for quick visualization.
4
- * Ideal for UI rendering with a specified number of points.
5
- *
6
- * @param options - The options for the preview, including file URI and time range.
7
- * @returns A promise that resolves to the audio preview data.
8
- */
9
- export async function extractPreview({ fileUri, numberOfPoints = 100, startTimeMs = 0, endTimeMs = 30000, // First 30 seconds
10
- decodingOptions, logger, }) {
11
- const durationMs = endTimeMs - startTimeMs;
12
- const segmentDurationMs = Math.floor(durationMs / numberOfPoints);
13
- // Call extractAudioAnalysis with calculated parameters
14
- const analysis = await extractAudioAnalysis({
15
- fileUri,
16
- startTimeMs,
17
- endTimeMs,
18
- logger,
19
- segmentDurationMs,
20
- decodingOptions,
21
- });
22
- // Transform the result into AudioPreview format
23
- return analysis;
24
- }
25
- //# sourceMappingURL=extractPreview.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractPreview.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractPreview.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACjC,OAAO,EACP,cAAc,GAAG,GAAG,EACpB,WAAW,GAAG,CAAC,EACf,SAAS,GAAG,KAAK,EAAE,mBAAmB;AACtC,eAAe,EACf,MAAM,GACO;IACb,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,CAAA;IAC1C,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,cAAc,CAAC,CAAA;IAEjE,uDAAuD;IACvD,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC;QACxC,OAAO;QACP,WAAW;QACX,SAAS;QACT,MAAM;QACN,iBAAiB;QACjB,eAAe;KAClB,CAAC,CAAA;IAEF,gDAAgD;IAChD,OAAO,QAAQ,CAAA;AACnB,CAAC","sourcesContent":["import { PreviewOptions, AudioAnalysis } from './AudioAnalysis.types'\nimport { extractAudioAnalysis } from './extractAudioAnalysis'\n\n/**\n * Generates a simplified preview of the audio waveform for quick visualization.\n * Ideal for UI rendering with a specified number of points.\n *\n * @param options - The options for the preview, including file URI and time range.\n * @returns A promise that resolves to the audio preview data.\n */\nexport async function extractPreview({\n fileUri,\n numberOfPoints = 100,\n startTimeMs = 0,\n endTimeMs = 30000, // First 30 seconds\n decodingOptions,\n logger,\n}: PreviewOptions): Promise<AudioAnalysis> {\n const durationMs = endTimeMs - startTimeMs\n const segmentDurationMs = Math.floor(durationMs / numberOfPoints)\n\n // Call extractAudioAnalysis with calculated parameters\n const analysis = await extractAudioAnalysis({\n fileUri,\n startTimeMs,\n endTimeMs,\n logger,\n segmentDurationMs,\n decodingOptions,\n })\n\n // Transform the result into AudioPreview format\n return analysis\n}\n"]}
@@ -1,8 +0,0 @@
1
- export interface ExtractWaveformProps {
2
- fileUri: string;
3
- numberOfSamples: number;
4
- offset?: number;
5
- length?: number;
6
- }
7
- export declare const extractWaveform: ({ fileUri, numberOfSamples, offset, length, }: ExtractWaveformProps) => Promise<unknown>;
8
- //# sourceMappingURL=extractWaveform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractWaveform.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AACD,eAAO,MAAM,eAAe,kDAKzB,oBAAoB,KAAG,QAAQ,OAAO,CAQxC,CAAA"}
@@ -1,11 +0,0 @@
1
- import ExpoAudioStreamModule from '../ExpoAudioStreamModule';
2
- export const extractWaveform = async ({ fileUri, numberOfSamples, offset = 0, length, }) => {
3
- const res = await ExpoAudioStreamModule.extractAudioAnalysis({
4
- fileUri,
5
- numberOfSamples,
6
- offset,
7
- length,
8
- });
9
- return res;
10
- };
11
- //# sourceMappingURL=extractWaveform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractWaveform.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,0BAA0B,CAAA;AAQ5D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EAClC,OAAO,EACP,eAAe,EACf,MAAM,GAAG,CAAC,EACV,MAAM,GACa,EAAoB,EAAE;IACzC,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;QACzD,OAAO;QACP,eAAe;QACf,MAAM;QACN,MAAM;KACT,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACd,CAAC,CAAA","sourcesContent":["import ExpoAudioStreamModule from '../ExpoAudioStreamModule'\n\nexport interface ExtractWaveformProps {\n fileUri: string\n numberOfSamples: number\n offset?: number\n length?: number\n}\nexport const extractWaveform = async ({\n fileUri,\n numberOfSamples,\n offset = 0,\n length,\n}: ExtractWaveformProps): Promise<unknown> => {\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n numberOfSamples,\n offset,\n length,\n })\n return res\n}\n"]}
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { UseAudioRecorderState } from './ExpoAudioStream.types';
3
- import { UseAudioRecorderProps } from './useAudioRecorder';
4
- interface AudioRecorderProviderProps {
5
- children: React.ReactNode;
6
- config?: UseAudioRecorderProps;
7
- }
8
- export declare const AudioRecorderProvider: React.FC<AudioRecorderProviderProps>;
9
- export declare const useSharedAudioRecorder: () => UseAudioRecorderState;
10
- export {};
11
- //# sourceMappingURL=AudioRecorder.provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AudioRecorder.provider.d.ts","sourceRoot":"","sources":["../src/AudioRecorder.provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAA;AAwB5E,UAAU,0BAA0B;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,CAAC,EAAE,qBAAqB,CAAA;CACjC;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAUtE,CAAA;AAED,eAAO,MAAM,sBAAsB,6BAQlC,CAAA"}
@@ -1,37 +0,0 @@
1
- // packages/expo-audio-stream/src/AudioRecorder.provider.tsx
2
- import React, { createContext, useContext } from 'react';
3
- import { useAudioRecorder } from './useAudioRecorder';
4
- const initContext = {
5
- isRecording: false,
6
- isPaused: false,
7
- durationMs: 0,
8
- size: 0,
9
- compression: undefined,
10
- startRecording: async () => {
11
- throw new Error('AudioRecorderProvider not found');
12
- },
13
- stopRecording: async () => {
14
- throw new Error('AudioRecorderProvider not found');
15
- },
16
- pauseRecording: async () => {
17
- throw new Error('AudioRecorderProvider not found');
18
- },
19
- resumeRecording: async () => {
20
- throw new Error('AudioRecorderProvider not found');
21
- },
22
- };
23
- const AudioRecorderContext = createContext(initContext);
24
- export const AudioRecorderProvider = ({ children, config = {}, }) => {
25
- const audioRecorder = useAudioRecorder(config);
26
- return (<AudioRecorderContext.Provider value={audioRecorder}>
27
- {children}
28
- </AudioRecorderContext.Provider>);
29
- };
30
- export const useSharedAudioRecorder = () => {
31
- const context = useContext(AudioRecorderContext);
32
- if (!context) {
33
- throw new Error('useSharedAudioRecorder must be used within an AudioRecorderProvider');
34
- }
35
- return context;
36
- };
37
- //# sourceMappingURL=AudioRecorder.provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AudioRecorder.provider.js","sourceRoot":"","sources":["../src/AudioRecorder.provider.tsx"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,EAAyB,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,MAAM,WAAW,GAA0B;IACvC,WAAW,EAAE,KAAK;IAClB,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,CAAC;IACb,IAAI,EAAE,CAAC;IACP,WAAW,EAAE,SAAS;IACtB,cAAc,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;IACD,aAAa,EAAE,KAAK,IAAI,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;IACD,cAAc,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;IACD,eAAe,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;CACJ,CAAA;AAED,MAAM,oBAAoB,GAAG,aAAa,CAAwB,WAAW,CAAC,CAAA;AAO9E,MAAM,CAAC,MAAM,qBAAqB,GAAyC,CAAC,EACxE,QAAQ,EACR,MAAM,GAAG,EAAE,GACd,EAAE,EAAE;IACD,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC9C,OAAO,CACH,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,CAChD;YAAA,CAAC,QAAQ,CACb;QAAA,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CACnC,CAAA;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACvC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAA;IAChD,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACX,qEAAqE,CACxE,CAAA;IACL,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA","sourcesContent":["// packages/expo-audio-stream/src/AudioRecorder.provider.tsx\nimport React, { createContext, useContext } from 'react'\n\nimport { UseAudioRecorderState } from './ExpoAudioStream.types'\nimport { UseAudioRecorderProps, useAudioRecorder } from './useAudioRecorder'\n\nconst initContext: UseAudioRecorderState = {\n isRecording: false,\n isPaused: false,\n durationMs: 0,\n size: 0,\n compression: undefined,\n startRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n stopRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n pauseRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n resumeRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n}\n\nconst AudioRecorderContext = createContext<UseAudioRecorderState>(initContext)\n\ninterface AudioRecorderProviderProps {\n children: React.ReactNode\n config?: UseAudioRecorderProps\n}\n\nexport const AudioRecorderProvider: React.FC<AudioRecorderProviderProps> = ({\n children,\n config = {},\n}) => {\n const audioRecorder = useAudioRecorder(config)\n return (\n <AudioRecorderContext.Provider value={audioRecorder}>\n {children}\n </AudioRecorderContext.Provider>\n )\n}\n\nexport const useSharedAudioRecorder = () => {\n const context = useContext(AudioRecorderContext)\n if (!context) {\n throw new Error(\n 'useSharedAudioRecorder must be used within an AudioRecorderProvider'\n )\n }\n return context\n}\n"]}
@@ -1,3 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
3
- //# sourceMappingURL=ExpoAudioStream.native.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoAudioStream.native.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.native.ts"],"names":[],"mappings":";AAKA,wBAAqD"}
@@ -1,6 +0,0 @@
1
- // src/ExpoAudioStreamModule.ts
2
- import { requireNativeModule } from 'expo-modules-core';
3
- // It loads the native module object from the JSI or falls back to
4
- // the bridge module (from NativeModulesProxy) if the remote debugger is on.
5
- export default requireNativeModule('ExpoAudioStream');
6
- //# sourceMappingURL=ExpoAudioStream.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoAudioStream.native.js","sourceRoot":"","sources":["../src/ExpoAudioStream.native.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEvD,kEAAkE;AAClE,4EAA4E;AAC5E,eAAe,mBAAmB,CAAC,iBAAiB,CAAC,CAAA","sourcesContent":["// src/ExpoAudioStreamModule.ts\nimport { requireNativeModule } from 'expo-modules-core'\n\n// It loads the native module object from the JSI or falls back to\n// the bridge module (from NativeModulesProxy) if the remote debugger is on.\nexport default requireNativeModule('ExpoAudioStream')\n"]}