@siteed/expo-audio-stream 1.0.3 → 1.0.5

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 (114) hide show
  1. package/.size-limit.json +4 -4
  2. package/README.md +18 -176
  3. package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +1 -0
  4. package/app.plugin.js +1 -1
  5. package/build/AudioAnalysis/AudioAnalysis.types.d.ts +3 -5
  6. package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -1
  7. package/build/AudioAnalysis/AudioAnalysis.types.js.map +1 -1
  8. package/build/AudioAnalysis/extractAudioAnalysis.d.ts +19 -3
  9. package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -1
  10. package/build/AudioAnalysis/extractAudioAnalysis.js +14 -27
  11. package/build/AudioAnalysis/extractAudioAnalysis.js.map +1 -1
  12. package/build/AudioAnalysis/extractWaveform.d.ts.map +1 -1
  13. package/build/AudioAnalysis/extractWaveform.js +3 -3
  14. package/build/AudioAnalysis/extractWaveform.js.map +1 -1
  15. package/build/AudioRecorder.provider.d.ts +6 -6
  16. package/build/AudioRecorder.provider.d.ts.map +1 -1
  17. package/build/AudioRecorder.provider.js +9 -9
  18. package/build/AudioRecorder.provider.js.map +1 -1
  19. package/build/ExpoAudioStream.native.d.ts.map +1 -1
  20. package/build/ExpoAudioStream.native.js +2 -2
  21. package/build/ExpoAudioStream.native.js.map +1 -1
  22. package/build/ExpoAudioStream.types.d.ts +20 -18
  23. package/build/ExpoAudioStream.types.d.ts.map +1 -1
  24. package/build/ExpoAudioStream.types.js.map +1 -1
  25. package/build/ExpoAudioStream.web.d.ts +8 -8
  26. package/build/ExpoAudioStream.web.d.ts.map +1 -1
  27. package/build/ExpoAudioStream.web.js +40 -22
  28. package/build/ExpoAudioStream.web.js.map +1 -1
  29. package/build/ExpoAudioStreamModule.d.ts.map +1 -1
  30. package/build/ExpoAudioStreamModule.js +8 -7
  31. package/build/ExpoAudioStreamModule.js.map +1 -1
  32. package/build/WebRecorder.web.d.ts +8 -8
  33. package/build/WebRecorder.web.d.ts.map +1 -1
  34. package/build/WebRecorder.web.js +60 -50
  35. package/build/WebRecorder.web.js.map +1 -1
  36. package/build/constants.d.ts +1 -1
  37. package/build/constants.d.ts.map +1 -1
  38. package/build/constants.js +3 -3
  39. package/build/constants.js.map +1 -1
  40. package/build/events.d.ts +16 -4
  41. package/build/events.d.ts.map +1 -1
  42. package/build/events.js +8 -8
  43. package/build/events.js.map +1 -1
  44. package/build/index.d.ts +8 -8
  45. package/build/index.d.ts.map +1 -1
  46. package/build/index.js +6 -6
  47. package/build/index.js.map +1 -1
  48. package/build/logger.d.ts +2 -2
  49. package/build/logger.d.ts.map +1 -1
  50. package/build/logger.js +7 -11
  51. package/build/logger.js.map +1 -1
  52. package/build/useAudioRecorder.d.ts +4 -21
  53. package/build/useAudioRecorder.d.ts.map +1 -1
  54. package/build/useAudioRecorder.js +33 -33
  55. package/build/useAudioRecorder.js.map +1 -1
  56. package/build/utils/BlobFix.d.ts +9 -0
  57. package/build/utils/BlobFix.d.ts.map +1 -0
  58. package/build/utils/BlobFix.js +494 -0
  59. package/build/utils/BlobFix.js.map +1 -0
  60. package/build/utils/concatenateBuffers.d.ts +8 -0
  61. package/build/utils/concatenateBuffers.d.ts.map +1 -0
  62. package/build/utils/concatenateBuffers.js +21 -0
  63. package/build/utils/concatenateBuffers.js.map +1 -0
  64. package/build/utils/convertPCMToFloat32.d.ts +2 -2
  65. package/build/utils/convertPCMToFloat32.d.ts.map +1 -1
  66. package/build/utils/convertPCMToFloat32.js +49 -36
  67. package/build/utils/convertPCMToFloat32.js.map +1 -1
  68. package/build/utils/encodingToBitDepth.d.ts +1 -1
  69. package/build/utils/encodingToBitDepth.d.ts.map +1 -1
  70. package/build/utils/encodingToBitDepth.js +3 -3
  71. package/build/utils/encodingToBitDepth.js.map +1 -1
  72. package/build/utils/getWavFileInfo.d.ts +4 -3
  73. package/build/utils/getWavFileInfo.d.ts.map +1 -1
  74. package/build/utils/getWavFileInfo.js +18 -15
  75. package/build/utils/getWavFileInfo.js.map +1 -1
  76. package/build/utils/writeWavHeader.d.ts.map +1 -1
  77. package/build/utils/writeWavHeader.js +4 -4
  78. package/build/utils/writeWavHeader.js.map +1 -1
  79. package/build/workers/InlineFeaturesExtractor.web.d.ts.map +1 -1
  80. package/build/workers/InlineFeaturesExtractor.web.js.map +1 -1
  81. package/build/workers/inlineAudioWebWorker.web.d.ts.map +1 -1
  82. package/build/workers/inlineAudioWebWorker.web.js.map +1 -1
  83. package/expo-module.config.json +8 -17
  84. package/ios/AudioStreamManager.swift +1 -0
  85. package/ios/ExpoAudioStreamModule.swift +1 -0
  86. package/ios/RecordingResult.swift +1 -0
  87. package/package.json +72 -65
  88. package/plugin/build/index.d.ts +1 -1
  89. package/plugin/build/index.js +7 -7
  90. package/plugin/src/index.ts +47 -47
  91. package/plugin/tsconfig.json +8 -13
  92. package/src/AudioAnalysis/AudioAnalysis.types.ts +59 -60
  93. package/src/AudioAnalysis/extractAudioAnalysis.ts +132 -121
  94. package/src/AudioAnalysis/extractWaveform.ts +18 -18
  95. package/src/AudioRecorder.provider.tsx +53 -53
  96. package/src/ExpoAudioStream.native.ts +2 -2
  97. package/src/ExpoAudioStream.types.ts +56 -53
  98. package/src/ExpoAudioStream.web.ts +232 -205
  99. package/src/ExpoAudioStreamModule.ts +17 -16
  100. package/src/WebRecorder.web.ts +407 -390
  101. package/src/constants.ts +11 -11
  102. package/src/events.ts +27 -13
  103. package/src/index.ts +15 -15
  104. package/src/logger.ts +15 -18
  105. package/src/useAudioRecorder.tsx +394 -389
  106. package/src/utils/BlobFix.ts +550 -0
  107. package/src/utils/concatenateBuffers.ts +24 -0
  108. package/src/utils/convertPCMToFloat32.ts +72 -45
  109. package/src/utils/encodingToBitDepth.ts +14 -14
  110. package/src/utils/getWavFileInfo.ts +106 -99
  111. package/src/utils/writeWavHeader.ts +45 -45
  112. package/src/workers/InlineFeaturesExtractor.web.tsx +1 -1
  113. package/src/workers/inlineAudioWebWorker.web.tsx +1 -1
  114. package/tsconfig.json +12 -7
package/.size-limit.json CHANGED
@@ -1,6 +1,6 @@
1
1
  [
2
- {
3
- "path": "./build/index.js",
4
- "limit": "100000 ms"
5
- }
2
+ {
3
+ "path": "./build/index.js",
4
+ "limit": "100000 ms"
5
+ }
6
6
  ]
package/README.md CHANGED
@@ -1,186 +1,28 @@
1
- # @siteed/expo-audio-stream
1
+ <div align="center">
2
+ <h1 align="center">
3
+ @siteed/expo-audio-stream
4
+ <br />
5
+ <br />
6
+ <strong>@siteed/expo-audio-stream<strong> is a comprehensive library designed to facilitate real-time audio processing and streaming across iOS, Android, and web platforms.
7
+ <br />
8
+ <br />
9
+ <a href="https://deeeed.github.io/expo-audio-stream/playground/">
10
+ <img src="../../docs/demo.gif" alt="Screenshot Playground">
11
+ </a>
12
+ </h1>
13
+ </div>
2
14
 
3
- `@siteed/expo-audio-stream` is a comprehensive library designed to facilitate real-time audio processing and streaming across iOS, Android, and web platforms.
4
15
 
5
16
  ## Features
6
17
 
7
18
  - Real-time audio streaming across iOS, Android, and web.
8
19
  - Configurable intervals for audio buffer receipt.
9
20
  - Automated microphone permissions setup in managed Expo projects.
10
- - IOS is automatically setup to handle background audio recording.
11
- - Listeners for audio data events with detailed event payloads.
12
- - Utility functions for recording control and file management.
21
+ - Background audio recording on iOS.
22
+ - Audio features extraction during recording.
23
+ - Consistent WAV PCM recording format across all platforms.
13
24
 
14
- ## Playground Example Application
25
+ ## Documentation
15
26
 
16
- The project comes with a fully functional example application that demonstrates how to use the library in a real-world scenario.
27
+ For detailed documentation, please refer to the [Getting Started Guide](https://deeeed.github.io/expo-audio-stream/docs/).
17
28
 
18
- ![Example App](./docs/demo.gif)
19
-
20
-
21
- To try it:
22
- ```bash
23
- git clone https://github.com/deeeed/expo-audio-stream.git
24
- cd expo-audio-stream
25
- yarn
26
- yarn playground ios
27
- yarn playground android
28
- yarn playground web
29
- ```
30
-
31
- ## Installation
32
-
33
- To install `@siteed/expo-audio-stream`, add it to your project using npm or Yarn:
34
-
35
- ```bash
36
- npm install @siteed/expo-audio-stream
37
- # or
38
- yarn add @siteed/expo-audio-stream
39
- ```
40
-
41
-
42
- ### Configuring with app.json
43
-
44
- To ensure expo-audio-stream works correctly with Expo, you must add it as a plugin in your app.json configuration file.
45
-
46
- ```json
47
- {
48
- "expo": {
49
- "plugins": ["@siteed/expo-audio-stream"]
50
- }
51
- }
52
- ```
53
-
54
- Make sure to run `npx expo prebuild` after adding the plugin to your app.json file.
55
-
56
- ## Usage
57
-
58
- This library provides two hooks: `useAudioRecorder` for standalone use and `useSharedAudioRecorder` for accessing shared recording state within a React context.
59
-
60
-
61
- ### Standalone Recording
62
-
63
- The `playground/` folder contains a fully functional React Native application demonstrating how to integrate and use `useAudioRecorder` from `@siteed/expo-audio-stream`. This includes starting and stopping recordings, handling permissions, and processing live audio data.
64
-
65
-
66
- #### Standalone Usage
67
-
68
- ```tsx
69
- import {
70
- useAudioRecorder,
71
- AudioStreamResult,
72
- } from '@siteed/expo-audio-stream';
73
-
74
- export default function App() {
75
- const { startRecording, stopRecording, duration, size, isRecording } = useAudioRecorder({
76
- debug: true,
77
- onAudioStream: (audioData: Blob) => {
78
- console.log(`audio event`,audioData);
79
- }
80
- });
81
-
82
- const handleStart = async () => {
83
- const { granted } = await Audio.requestPermissionsAsync();
84
- if (granted) {
85
- const fileUri = await startRecording({interval: 500});
86
- }
87
- };
88
-
89
- const handleStop = async () => {
90
- const result: AudioStreamResult = await stopRecording();
91
- };
92
-
93
- const renderRecording = () => (
94
- <View>
95
- <Text>Duration: {duration} ms</Text>
96
- <Text>Size: {size} bytes</Text>
97
- <Button title="Stop Recording" onPress={handleStop} />
98
- </View>
99
- );
100
-
101
- const renderStopped = () => (
102
- <View>
103
- <Button title="Start Recording" onPress={handleStart} />
104
- </View>
105
- );
106
-
107
- return (
108
- <View>
109
- <Button title="Request Permission" onPress={() => Audio.requestPermissionsAsync()} />
110
- {isRecording ? renderRecording() : renderStopped()}
111
- </View>
112
- );
113
- }
114
- ```
115
-
116
- The library also exposes an `addAudioEventListener` function that provides an `AudioEventPayload` object that you can subscribe to:
117
- ```tsx
118
- import { addAudioEventListener } from '@siteed/expo-audio-stream';
119
-
120
- useEffect(() => {
121
- const subscribe = addAudioEventListener(async ({fileUri, deltaSize, totalSize, from, streamUuid, encoded, mimeType, buffer}) => {
122
- log(`Received audio event:`, {fileUri, deltaSize, totalSize, mimeType, from, streamUuid, encodedLength: encoded?.length, bufferLength: buffer?.length})
123
- });
124
- return () => subscribe.remove();
125
- }, []);
126
- ```
127
-
128
- ### Shared Recording
129
-
130
- To facilitate state sharing across multiple components or screens, useSharedAudioRecorder can be used. It should be wrapped in a AudioRecorderProvider context provider to ensure state is managed at a higher level and shared appropriately.
131
-
132
- #### Shared Recording Usage
133
-
134
- ```tsx
135
- import { AudioRecorderProvider, useSharedAudioRecorder } from '@siteed/expo-audio-stream';
136
-
137
- export default function ParentComponent() {
138
- return (
139
- <AudioRecorderProvider>
140
- <ChildComponent />
141
- </AudioRecorderProvider>
142
- );
143
- }
144
-
145
- function ChildComponent() {
146
- const {
147
- startRecording,
148
- isRecording
149
- } = useSharedAudioRecorder();
150
-
151
- return (
152
- <View>
153
- <Text>{isRecording ? "Recording..." : "Ready to record"}</Text>
154
- <Button title="Toggle Recording" onPress={startRecording} />
155
- </View>
156
- );
157
- }
158
- ```
159
-
160
- ### Add Event Listener
161
-
162
- You can also add an event listener to receive detailed audio event payloads, which is crucial for both standalone and shared usage scenarios.
163
-
164
- ```tsx
165
- import { useEffect } from 'react';
166
- import { addAudioEventListener } from '@siteed/expo-audio-stream';
167
-
168
- function App() {
169
- useEffect(() => {
170
- const subscription = addAudioEventListener(event => {
171
- console.log("Audio event received:", event);
172
- });
173
-
174
- return () => subscription.remove();
175
- }, []);
176
-
177
- // UI code here
178
- }
179
- ```
180
-
181
- ## Recording configuration
182
-
183
- - on Android and IOS, audio is recorded in wav format, 16khz sample rate, 16 bit depth, 1 channel.
184
- - on web, it usually records in opus but it depends on the browser configuration.
185
-
186
- If you want to process the audio livestream directly, I recommend having another encoding step to align the audio format across platforms.
@@ -330,6 +330,7 @@ class AudioRecorderManager(
330
330
  // Create result bundle
331
331
  val result = bundleOf(
332
332
  "fileUri" to audioFile?.toURI().toString(),
333
+ "filename" to audioFile?.name,
333
334
  "durationMs" to duration,
334
335
  "channels" to recordingConfig.channels,
335
336
  "bitDepth" to when (recordingConfig.encoding) {
package/app.plugin.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("./plugin/build");
1
+ module.exports = require('./plugin/build')
@@ -49,10 +49,11 @@ export interface DataPoint {
49
49
  samples?: number;
50
50
  speaker?: number;
51
51
  }
52
+ export type AmplitudeAlgorithm = 'peak' | 'rms';
52
53
  /**
53
54
  * Represents the complete data from the audio analysis.
54
55
  */
55
- export interface AudioAnalysisData {
56
+ export interface AudioAnalysis {
56
57
  pointsPerSecond: number;
57
58
  durationMs: number;
58
59
  bitDepth: number;
@@ -60,6 +61,7 @@ export interface AudioAnalysisData {
60
61
  numberOfChannels: number;
61
62
  sampleRate: number;
62
63
  dataPoints: DataPoint[];
64
+ amplitudeAlgorithm: AmplitudeAlgorithm;
63
65
  amplitudeRange: {
64
66
  min: number;
65
67
  max: number;
@@ -69,8 +71,4 @@ export interface AudioAnalysisData {
69
71
  speaker: number;
70
72
  }[];
71
73
  }
72
- export interface AudioAnalysisEventPayload {
73
- analysis: AudioAnalysisData;
74
- visualizationDuration: number;
75
- }
76
74
  //# sourceMappingURL=AudioAnalysis.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AudioAnalysis.types.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/AudioAnalysis.types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC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AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,cAAc,EAAE;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IAEF,cAAc,CAAC,EAAE;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;CACL;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,qBAAqB,EAAE,MAAM,CAAC;CAC/B"}
1
+ {"version":3,"file":"AudioAnalysis.types.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/AudioAnalysis.types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,GAAG,CAAC,EAAE,O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AE;QACb,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;KAClB,EAAE,CAAA;CACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"AudioAnalysis.types.js","sourceRoot":"","sources":["../../src/AudioAnalysis/AudioAnalysis.types.ts"],"names":[],"mappings":"AAAA,sEAAsE","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/AudioAnalysis.types.ts\n\n/**\n * Represents various audio features extracted from an audio signal.\n */\nexport interface AudioFeatures {\n energy: number; // The infinite integral of the squared signal, representing the overall energy of the audio.\n mfcc: number[]; // Mel-frequency cepstral coefficients, describing the short-term power spectrum of a sound.\n rms: number; // Root mean square value, indicating the amplitude of the audio signal.\n minAmplitude: number; // Minimum amplitude value in the audio signal.\n maxAmplitude: number; // Maximum amplitude value in the audio signal.\n zcr: number; // Zero-crossing rate, indicating the rate at which the signal changes sign.\n spectralCentroid: number; // The center of mass of the spectrum, indicating the brightness of the sound.\n spectralFlatness: number; // Measure of the flatness of the spectrum, indicating how noise-like the signal is.\n spectralRolloff: number; // The frequency below which a specified percentage (usually 85%) of the total spectral energy lies.\n spectralBandwidth: number; // The width of the spectrum, indicating the range of frequencies present.\n chromagram: number[]; // Chromagram, representing the 12 different pitch classes of the audio.\n tempo: number; // Estimated tempo of the audio signal, measured in beats per minute (BPM).\n hnr: number; // Harmonics-to-noise ratio, indicating the proportion of harmonics to noise in the audio signal.\n}\n\n/**\n * Options to specify which audio features to extract.\n */\nexport interface AudioFeaturesOptions {\n energy?: boolean;\n mfcc?: boolean;\n rms?: boolean;\n zcr?: boolean;\n spectralCentroid?: boolean;\n spectralFlatness?: boolean;\n spectralRolloff?: boolean;\n spectralBandwidth?: boolean;\n chromagram?: boolean;\n tempo?: boolean;\n hnr?: boolean;\n}\n\n/**\n * Represents a single data point in the audio analysis.\n */\nexport interface DataPoint {\n id: number;\n amplitude: number;\n activeSpeech?: boolean;\n dB?: number;\n silent?: boolean;\n features?: AudioFeatures;\n startTime?: number;\n endTime?: number;\n // start / end position in bytes\n startPosition?: number;\n endPosition?: number;\n // number of audio samples for this point (samples size depends on bit depth)\n samples?: number;\n // TODO: speaker detection\n speaker?: number;\n}\n\n/**\n * Represents the complete data from the audio analysis.\n */\nexport interface AudioAnalysisData {\n pointsPerSecond: number; // How many consolidated value per second\n durationMs: number; // Duration of the audio in milliseconds\n bitDepth: number; // Bit depth of the audio\n samples: number; // Size of the audio in bytes\n numberOfChannels: number; // Number of audio channels\n sampleRate: number; // Sample rate of the audio\n dataPoints: DataPoint[]; // Array of data points from the analysis.\n amplitudeRange: {\n min: number;\n max: number;\n };\n // TODO: speaker detection\n speakerChanges?: {\n timestamp: number; // Timestamp of the speaker change in milliseconds.\n speaker: number; // Speaker identifier.\n }[];\n}\n\nexport interface AudioAnalysisEventPayload {\n analysis: AudioAnalysisData;\n visualizationDuration: number;\n}\n"]}
1
+ {"version":3,"file":"AudioAnalysis.types.js","sourceRoot":"","sources":["../../src/AudioAnalysis/AudioAnalysis.types.ts"],"names":[],"mappings":"AAAA,sEAAsE","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/AudioAnalysis.types.ts\n\n/**\n * Represents various audio features extracted from an audio signal.\n */\nexport interface AudioFeatures {\n energy: number // The infinite integral of the squared signal, representing the overall energy of the audio.\n mfcc: number[] // Mel-frequency cepstral coefficients, describing the short-term power spectrum of a sound.\n rms: number // Root mean square value, indicating the amplitude of the audio signal.\n minAmplitude: number // Minimum amplitude value in the audio signal.\n maxAmplitude: number // Maximum amplitude value in the audio signal.\n zcr: number // Zero-crossing rate, indicating the rate at which the signal changes sign.\n spectralCentroid: number // The center of mass of the spectrum, indicating the brightness of the sound.\n spectralFlatness: number // Measure of the flatness of the spectrum, indicating how noise-like the signal is.\n spectralRolloff: number // The frequency below which a specified percentage (usually 85%) of the total spectral energy lies.\n spectralBandwidth: number // The width of the spectrum, indicating the range of frequencies present.\n chromagram: number[] // Chromagram, representing the 12 different pitch classes of the audio.\n tempo: number // Estimated tempo of the audio signal, measured in beats per minute (BPM).\n hnr: number // Harmonics-to-noise ratio, indicating the proportion of harmonics to noise in the audio signal.\n}\n\n/**\n * Options to specify which audio features to extract.\n */\nexport interface AudioFeaturesOptions {\n energy?: boolean\n mfcc?: boolean\n rms?: boolean\n zcr?: boolean\n spectralCentroid?: boolean\n spectralFlatness?: boolean\n spectralRolloff?: boolean\n spectralBandwidth?: boolean\n chromagram?: boolean\n tempo?: boolean\n hnr?: boolean\n}\n\n/**\n * Represents a single data point in the audio analysis.\n */\nexport interface DataPoint {\n id: number\n amplitude: number\n activeSpeech?: boolean\n dB?: number\n silent?: boolean\n features?: AudioFeatures\n startTime?: number\n endTime?: number\n // start / end position in bytes\n startPosition?: number\n endPosition?: number\n // number of audio samples for this point (samples size depends on bit depth)\n samples?: number\n // TODO: speaker detection\n speaker?: number\n}\n\nexport type AmplitudeAlgorithm = 'peak' | 'rms'\n\n/**\n * Represents the complete data from the audio analysis.\n */\nexport interface AudioAnalysis {\n pointsPerSecond: number // How many consolidated value per second\n durationMs: number // Duration of the audio in milliseconds\n bitDepth: number // Bit depth of the audio\n samples: number // Size of the audio in bytes\n numberOfChannels: number // Number of audio channels\n sampleRate: number // Sample rate of the audio\n dataPoints: DataPoint[] // Array of data points from the analysis.\n amplitudeAlgorithm: AmplitudeAlgorithm // Algorithm used to calculate amplitude values.\n amplitudeRange: {\n min: number\n max: number\n }\n // TODO: speaker detection\n speakerChanges?: {\n timestamp: number // Timestamp of the speaker change in milliseconds.\n speaker: number // Speaker identifier.\n }[]\n}\n\n"]}
@@ -1,4 +1,20 @@
1
- import { AudioAnalysisData } from "./AudioAnalysis.types";
2
- import { ExtractMetadataProps } from "../useAudioRecorder";
3
- export declare const extractAudioAnalysis: ({ fileUri, pointsPerSecond, arrayBuffer, bitDepth, skipWavHeader, durationMs, sampleRate, numberOfChannels, algorithm, features, featuresExtratorUrl, }: ExtractMetadataProps) => Promise<AudioAnalysisData>;
1
+ import { AmplitudeAlgorithm, AudioAnalysis, AudioFeaturesOptions } from './AudioAnalysis.types';
2
+ import { WavFileInfo } from '../utils/getWavFileInfo';
3
+ export interface ExtractAudioAnalysisProps {
4
+ fileUri?: string;
5
+ wavMetadata?: WavFileInfo;
6
+ arrayBuffer?: ArrayBuffer;
7
+ bitDepth?: number;
8
+ skipWavHeader?: boolean;
9
+ durationMs?: number;
10
+ sampleRate?: number;
11
+ numberOfChannels?: number;
12
+ algorithm?: AmplitudeAlgorithm;
13
+ position?: number;
14
+ length?: number;
15
+ pointsPerSecond?: number;
16
+ features?: AudioFeaturesOptions;
17
+ featuresExtratorUrl?: string;
18
+ }
19
+ export declare const extractAudioAnalysis: ({ fileUri, pointsPerSecond, arrayBuffer, bitDepth, skipWavHeader, durationMs, sampleRate, numberOfChannels, algorithm, features, featuresExtratorUrl, }: ExtractAudioAnalysisProps) => Promise<AudioAnalysis>;
4
20
  //# sourceMappingURL=extractAudioAnalysis.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extractAudioAnalysis.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioAnalysis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAO3D,eAAO,MAAM,oBAAoB,4JAY9B,oBAAoB,KAAG,OAAO,CAAC,iBAAiB,CA+GlD,CAAC"}
1
+ {"version":3,"file":"extractAudioAnalysis.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioAnalysis.ts"],"names":[],"mappings":"AACA,OAAO,EACH,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACvB,MAAM,uBAAuB,CAAA;AAK9B,OAAO,EAAkB,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAKrE,MAAM,WAAW,yBAAyB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,kBAAkB,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,oBAAoB,CAAA;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,eAAO,MAAM,oBAAoB,4JAY9B,yBAAyB,KAAG,OAAO,CAAC,aAAa,CAsGnD,CAAA"}
@@ -1,14 +1,14 @@
1
- import ExpoAudioStreamModule from "../ExpoAudioStreamModule";
2
- import { isWeb } from "../constants";
3
- import { getLogger } from "../logger";
4
- import { convertPCMToFloat32 } from "../utils/convertPCMToFloat32";
5
- import { getWavFileInfo } from "../utils/getWavFileInfo";
6
- import { InlineFeaturesExtractor } from "../workers/InlineFeaturesExtractor.web";
7
- const logger = getLogger("extractAudioAnalysis");
8
- export const extractAudioAnalysis = async ({ fileUri, pointsPerSecond = 20, arrayBuffer, bitDepth, skipWavHeader, durationMs, sampleRate, numberOfChannels, algorithm = "rms", features, featuresExtratorUrl, }) => {
1
+ import ExpoAudioStreamModule from '../ExpoAudioStreamModule';
2
+ import { isWeb } from '../constants';
3
+ import { getLogger } from '../logger';
4
+ import { convertPCMToFloat32 } from '../utils/convertPCMToFloat32';
5
+ import { getWavFileInfo } from '../utils/getWavFileInfo';
6
+ import { InlineFeaturesExtractor } from '../workers/InlineFeaturesExtractor.web';
7
+ const logger = getLogger('extractAudioAnalysis');
8
+ export const extractAudioAnalysis = async ({ fileUri, pointsPerSecond = 20, arrayBuffer, bitDepth, skipWavHeader = true, durationMs, sampleRate, numberOfChannels, algorithm = 'rms', features, featuresExtratorUrl, }) => {
9
9
  if (isWeb) {
10
10
  if (!arrayBuffer && !fileUri) {
11
- throw new Error("Either arrayBuffer or fileUri must be provided");
11
+ throw new Error('Either arrayBuffer or fileUri must be provided');
12
12
  }
13
13
  if (!arrayBuffer) {
14
14
  logger.log(`fetching fileUri`, fileUri);
@@ -16,7 +16,7 @@ export const extractAudioAnalysis = async ({ fileUri, pointsPerSecond = 20, arra
16
16
  if (!response.ok) {
17
17
  throw new Error(`Failed to fetch fileUri: ${response.statusText}`);
18
18
  }
19
- arrayBuffer = (await response.arrayBuffer()).slice(0);
19
+ arrayBuffer = await response.arrayBuffer();
20
20
  logger.log(`fetched fileUri`, arrayBuffer.byteLength, arrayBuffer);
21
21
  }
22
22
  // Create a new copy of the ArrayBuffer to avoid detachment issues
@@ -29,20 +29,7 @@ export const extractAudioAnalysis = async ({ fileUri, pointsPerSecond = 20, arra
29
29
  actualBitDepth = fileInfo.bitDepth;
30
30
  }
31
31
  logger.log(`extractAudioAnalysis actualBitDepth=${actualBitDepth}`);
32
- // let copyChannelData: Float32Array;
33
- // try {
34
- // const audioContext = new (window.AudioContext ||
35
- // // @ts-ignore
36
- // window.webkitAudioContext)();
37
- // const audioBuffer = await audioContext.decodeAudioData(bufferCopy);
38
- // const channelData = audioBuffer.getChannelData(0); // Use only the first channel
39
- // copyChannelData = new Float32Array(channelData); // Create a new Float32Array
40
- // } catch (error) {
41
- // console.warn("Failed to decode audio data:", error);
42
- // // Fall back to creating a new Float32Array from the ArrayBuffer if decoding fails
43
- // copyChannelData = new Float32Array(arrayBuffer);
44
- // }
45
- const { pcmValues: channelData, min, max, } = convertPCMToFloat32({
32
+ const { pcmValues: channelData, min, max, } = await convertPCMToFloat32({
46
33
  buffer: arrayBuffer,
47
34
  bitDepth: actualBitDepth,
48
35
  skipWavHeader,
@@ -55,7 +42,7 @@ export const extractAudioAnalysis = async ({ fileUri, pointsPerSecond = 20, arra
55
42
  }
56
43
  else {
57
44
  const blob = new Blob([InlineFeaturesExtractor], {
58
- type: "application/javascript",
45
+ type: 'application/javascript',
59
46
  });
60
47
  const url = URL.createObjectURL(blob);
61
48
  worker = new Worker(url);
@@ -67,7 +54,7 @@ export const extractAudioAnalysis = async ({ fileUri, pointsPerSecond = 20, arra
67
54
  reject(error);
68
55
  };
69
56
  worker.postMessage({
70
- command: "process",
57
+ command: 'process',
71
58
  channelData,
72
59
  sampleRate,
73
60
  pointsPerSecond,
@@ -80,7 +67,7 @@ export const extractAudioAnalysis = async ({ fileUri, pointsPerSecond = 20, arra
80
67
  }
81
68
  else {
82
69
  if (!fileUri) {
83
- throw new Error("fileUri is required");
70
+ throw new Error('fileUri is required');
84
71
  }
85
72
  logger.log(`extractAudioAnalysis`, {
86
73
  fileUri,
@@ -1 +1 @@
1
- {"version":3,"file":"extractAudioAnalysis.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioAnalysis.ts"],"names":[],"mappings":"AAEA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,MAAM,MAAM,GAAG,SAAS,CAAC,sBAAsB,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACzC,OAAO,EACP,eAAe,GAAG,EAAE,EACpB,WAAW,EACX,QAAQ,EACR,aAAa,EACb,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,SAAS,GAAG,KAAK,EACjB,QAAQ,EACR,mBAAmB,GACE,EAA8B,EAAE;IACrD,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,CAAC,WA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AQ;gBACR,mBAAmB,EAAE,UAAU;gBAC/B,gBAAgB;aACjB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE;YACjC,OAAO;YACP,eAAe;YACf,SAAS;SACV,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;YAC3D,OAAO;YACP,eAAe;YACf,aAAa;YACb,SAAS;YACT,QAAQ;SACT,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;QACxC,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC,CAAC","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts\nimport { AudioAnalysisData } from \"./AudioAnalysis.types\";\nimport ExpoAudioStreamModule from \"../ExpoAudioStreamModule\";\nimport { isWeb } from \"../constants\";\nimport { getLogger } from \"../logger\";\nimport { ExtractMetadataProps } from \"../useAudioRecorder\";\nimport { convertPCMToFloat32 } from \"../utils/convertPCMToFloat32\";\nimport { getWavFileInfo } from \"../utils/getWavFileInfo\";\nimport { InlineFeaturesExtractor } from \"../workers/InlineFeaturesExtractor.web\";\n\nconst logger = getLogger(\"extractAudioAnalysis\");\n\nexport const extractAudioAnalysis = async ({\n fileUri,\n pointsPerSecond = 20,\n arrayBuffer,\n bitDepth,\n skipWavHeader,\n durationMs,\n sampleRate,\n numberOfChannels,\n algorithm = \"rms\",\n features,\n featuresExtratorUrl,\n}: ExtractMetadataProps): Promise<AudioAnalysisData> => {\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(`Failed to fetch fileUri: ${response.statusText}`);\n }\n\n arrayBuffer = (await response.arrayBuffer()).slice(0);\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 skipWavHeader=${skipWavHeader} 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 // let copyChannelData: Float32Array;\n // try {\n // const audioContext = new (window.AudioContext ||\n // // @ts-ignore\n // window.webkitAudioContext)();\n // const audioBuffer = await audioContext.decodeAudioData(bufferCopy);\n // const channelData = audioBuffer.getChannelData(0); // Use only the first channel\n // copyChannelData = new Float32Array(channelData); // Create a new Float32Array\n // } catch (error) {\n // console.warn(\"Failed to decode audio data:\", error);\n // // Fall back to creating a new Float32Array from the ArrayBuffer if decoding fails\n // copyChannelData = new Float32Array(arrayBuffer);\n // }\n\n const {\n pcmValues: channelData,\n min,\n max,\n } = convertPCMToFloat32({\n buffer: arrayBuffer,\n bitDepth: actualBitDepth,\n skipWavHeader,\n });\n logger.log(\n `extractAudioAnalysis skipWaveHeader=${skipWavHeader} convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`,\n );\n\n return new Promise((resolve, reject) => {\n let worker: Worker;\n if (featuresExtratorUrl) {\n worker = new Worker(new URL(featuresExtratorUrl, window.location.href));\n } else {\n const blob = new Blob([InlineFeaturesExtractor], {\n type: \"application/javascript\",\n });\n const url = URL.createObjectURL(blob);\n worker = new Worker(url);\n }\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,\n sampleRate,\n pointsPerSecond,\n algorithm,\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 pointsPerSecond,\n algorithm,\n });\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n pointsPerSecond,\n skipWavHeader,\n algorithm,\n features,\n });\n logger.log(`extractAudioAnalysis`, res);\n return res;\n }\n};\n"]}
1
+ {"version":3,"file":"extractAudioAnalysis.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioAnalysis.ts"],"names":[],"mappings":"AAMA,OAAO,qBAAqB,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,cAAc,EAAe,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEhF,MAAM,MAAM,GAAG,SAAS,CAAC,sBAAsB,CAAC,CAAA;AAmBhD,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACvC,OAAO,EACP,eAAe,GAAG,EAAE,EACpB,WAAW,EACX,QAAQ,EACR,aAAa,GAAG,IAAI,EACpB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,SAAS,GAAG,KAAK,EACjB,QAAQ,EACR,mBAAmB,GACK,EAA0B,EAAE;IACpD,IAAI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAC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AG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,OAAO;YACP,eAAe;YACf,aAAa;YACb,SAAS;YACT,QAAQ;SACX,CAAC,CAAA;QACF,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;QACvC,OAAO,GAAG,CAAA;IACd,CAAC;AACL,CAAC,CAAA","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts\nimport {\n AmplitudeAlgorithm,\n AudioAnalysis,\n AudioFeaturesOptions,\n} from './AudioAnalysis.types'\nimport ExpoAudioStreamModule from '../ExpoAudioStreamModule'\nimport { isWeb } from '../constants'\nimport { getLogger } from '../logger'\nimport { convertPCMToFloat32 } from '../utils/convertPCMToFloat32'\nimport { getWavFileInfo, WavFileInfo } from '../utils/getWavFileInfo'\nimport { InlineFeaturesExtractor } from '../workers/InlineFeaturesExtractor.web'\n\nconst logger = getLogger('extractAudioAnalysis')\n\nexport interface ExtractAudioAnalysisProps {\n fileUri?: string // should provide either fileUri or arrayBuffer\n wavMetadata?: WavFileInfo\n arrayBuffer?: ArrayBuffer\n bitDepth?: number\n skipWavHeader?: boolean\n durationMs?: number\n sampleRate?: number\n numberOfChannels?: number\n algorithm?: AmplitudeAlgorithm\n position?: number // Optional number of bytes to skip. Default is 0\n length?: number // Optional number of bytes to read.\n pointsPerSecond?: 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}\n\nexport const extractAudioAnalysis = async ({\n fileUri,\n pointsPerSecond = 20,\n arrayBuffer,\n bitDepth,\n skipWavHeader = true,\n durationMs,\n sampleRate,\n numberOfChannels,\n algorithm = 'rms',\n features,\n featuresExtratorUrl,\n}: ExtractAudioAnalysisProps): 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 skipWavHeader=${skipWavHeader} 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 skipWavHeader,\n })\n logger.log(\n `extractAudioAnalysis skipWaveHeader=${skipWavHeader} convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`\n )\n\n return new Promise((resolve, reject) => {\n let worker: Worker\n if (featuresExtratorUrl) {\n worker = new Worker(\n new URL(featuresExtratorUrl, window.location.href)\n )\n } else {\n const blob = new Blob([InlineFeaturesExtractor], {\n type: 'application/javascript',\n })\n const url = URL.createObjectURL(blob)\n worker = new Worker(url)\n }\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,\n sampleRate,\n pointsPerSecond,\n algorithm,\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 pointsPerSecond,\n algorithm,\n })\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n pointsPerSecond,\n skipWavHeader,\n algorithm,\n features,\n })\n logger.log(`extractAudioAnalysis`, res)\n return res\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"extractWaveform.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,eAAO,MAAM,eAAe,kDAKzB,oBAAoB,KAAG,OAAO,CAAC,OAAO,CASxC,CAAC"}
1
+ {"version":3,"file":"extractWaveform.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAIA,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,OAAO,CAAC,OAAO,CASxC,CAAA"}
@@ -1,6 +1,6 @@
1
- import ExpoAudioStreamModule from "../ExpoAudioStreamModule";
2
- import { getLogger } from "../logger";
3
- const logger = getLogger("extractWaveform");
1
+ import ExpoAudioStreamModule from '../ExpoAudioStreamModule';
2
+ import { getLogger } from '../logger';
3
+ const logger = getLogger('extractWaveform');
4
4
  export const extractWaveform = async ({ fileUri, numberOfSamples, offset = 0, length, }) => {
5
5
  const res = await ExpoAudioStreamModule.extractAudioAnalysis({
6
6
  fileUri,
@@ -1 +1 @@
1
- {"version":3,"file":"extractWaveform.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAO5C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,OAAO,EACP,eAAe,EACf,MAAM,GAAG,CAAC,EACV,MAAM,GACe,EAAoB,EAAE;IAC3C,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;QAC3D,OAAO;QACP,eAAe;QACf,MAAM;QACN,MAAM;KACP,CAAC,CAAC;IACH,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC","sourcesContent":["import ExpoAudioStreamModule from \"../ExpoAudioStreamModule\";\nimport { getLogger } from \"../logger\";\n\nconst logger = getLogger(\"extractWaveform\");\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 logger.log(`extractWaveform`, res);\n return res;\n};\n"]}
1
+ {"version":3,"file":"extractWaveform.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,MAAM,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAA;AAO3C,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,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;IAClC,OAAO,GAAG,CAAA;AACd,CAAC,CAAA","sourcesContent":["import ExpoAudioStreamModule from '../ExpoAudioStreamModule'\nimport { getLogger } from '../logger'\n\nconst logger = getLogger('extractWaveform')\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 logger.log(`extractWaveform`, res)\n return res\n}\n"]}
@@ -1,17 +1,17 @@
1
- import React from "react";
2
- import { AudioAnalysisData } from "./AudioAnalysis/AudioAnalysis.types";
3
- import { AudioRecordingResult, RecordingConfig, StartRecordingResult } from "./ExpoAudioStream.types";
4
- import { UseAudioRecorderProps } from "./useAudioRecorder";
1
+ import React from 'react';
2
+ import { AudioAnalysis } from './AudioAnalysis/AudioAnalysis.types';
3
+ import { AudioRecording, RecordingConfig, StartRecordingResult } from './ExpoAudioStream.types';
4
+ import { UseAudioRecorderProps } from './useAudioRecorder';
5
5
  export interface UseAudioRecorderState {
6
6
  startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>;
7
- stopRecording: () => Promise<AudioRecordingResult | null>;
7
+ stopRecording: () => Promise<AudioRecording | null>;
8
8
  pauseRecording: () => void;
9
9
  resumeRecording: () => void;
10
10
  isRecording: boolean;
11
11
  isPaused: boolean;
12
12
  durationMs: number;
13
13
  size: number;
14
- analysisData?: AudioAnalysisData;
14
+ analysisData?: AudioAnalysis;
15
15
  }
16
16
  interface AudioRecorderProviderProps {
17
17
  children: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"AudioRecorder.provider.d.ts","sourceRoot":"","sources":["../src/AudioRecorder.provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAC;AAE7E,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACtE,aAAa,EAAE,MAAM,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAC1D,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAClC;AAuBD,UAAU,0BAA0B;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAUtE,CAAC;AAEF,eAAO,MAAM,sBAAsB,6BAQlC,CAAC"}
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,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EACH,cAAc,EACd,eAAe,EACf,oBAAoB,EACvB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAA;AAE5E,MAAM,WAAW,qBAAqB;IAClC,cAAc,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACrE,aAAa,EAAE,MAAM,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACnD,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,eAAe,EAAE,MAAM,IAAI,CAAA;IAC3B,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,aAAa,CAAA;CAC/B;AAuBD,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,35 +1,35 @@
1
1
  // packages/expo-audio-stream/src/AudioRecorder.provider.tsx
2
- import React, { createContext, useContext } from "react";
3
- import { useAudioRecorder } from "./useAudioRecorder";
2
+ import React, { createContext, useContext } from 'react';
3
+ import { useAudioRecorder } from './useAudioRecorder';
4
4
  const initContext = {
5
5
  isRecording: false,
6
6
  isPaused: false,
7
7
  durationMs: 0,
8
8
  size: 0,
9
9
  startRecording: async () => {
10
- throw new Error("AudioRecorderProvider not found");
10
+ throw new Error('AudioRecorderProvider not found');
11
11
  },
12
12
  stopRecording: async () => {
13
- throw new Error("AudioRecorderProvider not found");
13
+ throw new Error('AudioRecorderProvider not found');
14
14
  },
15
15
  pauseRecording: () => {
16
- throw new Error("AudioRecorderProvider not found");
16
+ throw new Error('AudioRecorderProvider not found');
17
17
  },
18
18
  resumeRecording: () => {
19
- throw new Error("AudioRecorderProvider not found");
19
+ throw new Error('AudioRecorderProvider not found');
20
20
  },
21
21
  };
22
22
  const AudioRecorderContext = createContext(initContext);
23
23
  export const AudioRecorderProvider = ({ children, config = {}, }) => {
24
24
  const audioRecorder = useAudioRecorder(config);
25
25
  return (<AudioRecorderContext.Provider value={audioRecorder}>
26
- {children}
27
- </AudioRecorderContext.Provider>);
26
+ {children}
27
+ </AudioRecorderContext.Provider>);
28
28
  };
29
29
  export const useSharedAudioRecorder = () => {
30
30
  const context = useContext(AudioRecorderContext);
31
31
  if (!context) {
32
- throw new Error("useSharedAudioRecorder must be used within an AudioRecorderProvider");
32
+ throw new Error('useSharedAudioRecorder must be used within an AudioRecorderProvider');
33
33
  }
34
34
  return context;
35
35
  };
@@ -1 +1 @@
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,CAAC;AAQzD,OAAO,EAAyB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAc7E,MAAM,WAAW,GAA0B;IACzC,WAAW,EAAE,KAAK;IAClB,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,CAAC;IACb,IAAI,EAAE,CAAC;IACP,cAAc,EAAE,KAAK,IAAI,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,aAAa,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,cAAc,EAAE,GAAG,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,eAAe,EAAE,GAAG,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CACF,CAAC;AAEF,MAAM,oBAAoB,GAAG,aAAa,CAAwB,WAAW,CAAC,CAAC;AAO/E,MAAM,CAAC,MAAM,qBAAqB,GAAyC,CAAC,EAC1E,QAAQ,EACR,MAAM,GAAG,EAAE,GACZ,EAAE,EAAE;IACH,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,CACL,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,CAClD;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// packages/expo-audio-stream/src/AudioRecorder.provider.tsx\nimport React, { createContext, useContext } from \"react\";\n\nimport { AudioAnalysisData } from \"./AudioAnalysis/AudioAnalysis.types\";\nimport {\n AudioRecordingResult,\n RecordingConfig,\n StartRecordingResult,\n} from \"./ExpoAudioStream.types\";\nimport { UseAudioRecorderProps, useAudioRecorder } from \"./useAudioRecorder\";\n\nexport interface UseAudioRecorderState {\n startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>;\n stopRecording: () => Promise<AudioRecordingResult | null>;\n pauseRecording: () => void;\n resumeRecording: () => void;\n isRecording: boolean;\n isPaused: boolean;\n durationMs: number; // Duration of the recording\n size: number; // Size in bytes of the recorded audio\n analysisData?: AudioAnalysisData;\n}\n\nconst initContext: UseAudioRecorderState = {\n isRecording: false,\n isPaused: false,\n durationMs: 0,\n size: 0,\n startRecording: async () => {\n throw new Error(\"AudioRecorderProvider not found\");\n },\n stopRecording: async () => {\n throw new Error(\"AudioRecorderProvider not found\");\n },\n pauseRecording: () => {\n throw new Error(\"AudioRecorderProvider not found\");\n },\n resumeRecording: () => {\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
+ {"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;AAQxD,OAAO,EAAyB,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAc5E,MAAM,WAAW,GAA0B;IACvC,WAAW,EAAE,KAAK;IAClB,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,CAAC;IACb,IAAI,EAAE,CAAC;IACP,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,GAAG,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;IACD,eAAe,EAAE,GAAG,EAAE;QAClB,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 { AudioAnalysis } from './AudioAnalysis/AudioAnalysis.types'\nimport {\n AudioRecording,\n RecordingConfig,\n StartRecordingResult,\n} from './ExpoAudioStream.types'\nimport { UseAudioRecorderProps, useAudioRecorder } from './useAudioRecorder'\n\nexport interface UseAudioRecorderState {\n startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>\n stopRecording: () => Promise<AudioRecording | null>\n pauseRecording: () => void\n resumeRecording: () => void\n isRecording: boolean\n isPaused: boolean\n durationMs: number // Duration of the recording\n size: number // Size in bytes of the recorded audio\n analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag\n}\n\nconst initContext: UseAudioRecorderState = {\n isRecording: false,\n isPaused: false,\n durationMs: 0,\n size: 0,\n startRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n stopRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n pauseRecording: () => {\n throw new Error('AudioRecorderProvider not found')\n },\n resumeRecording: () => {\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 +1 @@
1
- {"version":3,"file":"ExpoAudioStream.native.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.native.ts"],"names":[],"mappings":";AAKA,wBAAsD"}
1
+ {"version":3,"file":"ExpoAudioStream.native.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.native.ts"],"names":[],"mappings":";AAKA,wBAAqD"}
@@ -1,6 +1,6 @@
1
1
  // src/ExpoAudioStreamModule.ts
2
- import { requireNativeModule } from "expo-modules-core";
2
+ import { requireNativeModule } from 'expo-modules-core';
3
3
  // It loads the native module object from the JSI or falls back to
4
4
  // the bridge module (from NativeModulesProxy) if the remote debugger is on.
5
- export default requireNativeModule("ExpoAudioStream");
5
+ export default requireNativeModule('ExpoAudioStream');
6
6
  //# sourceMappingURL=ExpoAudioStream.native.js.map
@@ -1 +1 @@
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,CAAC;AAExD,kEAAkE;AAClE,4EAA4E;AAC5E,eAAe,mBAAmB,CAAC,iBAAiB,CAAC,CAAC","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"]}
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"]}