@siteed/expo-audio-studio 2.4.1 → 2.6.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.
- package/CHANGELOG.md +14 -1
- package/README.md +25 -0
- package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +22 -0
- package/android/src/main/java/net/siteed/audiostream/AudioDeviceManager.kt +1501 -0
- package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +10 -5
- package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +27 -25
- package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +73 -71
- package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +576 -252
- package/android/src/main/java/net/siteed/audiostream/Constants.kt +17 -1
- package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +419 -155
- package/android/src/main/java/net/siteed/audiostream/LogUtils.kt +65 -0
- package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +9 -1
- package/build/AudioAnalysis/AudioAnalysis.types.js.map +1 -1
- package/build/AudioDeviceManager.d.ts +107 -0
- package/build/AudioDeviceManager.d.ts.map +1 -0
- package/build/AudioDeviceManager.js +493 -0
- package/build/AudioDeviceManager.js.map +1 -0
- package/build/AudioRecorder.provider.d.ts.map +1 -1
- package/build/AudioRecorder.provider.js +3 -0
- package/build/AudioRecorder.provider.js.map +1 -1
- package/build/ExpoAudioStream.types.d.ts +104 -1
- package/build/ExpoAudioStream.types.d.ts.map +1 -1
- package/build/ExpoAudioStream.types.js +7 -1
- package/build/ExpoAudioStream.types.js.map +1 -1
- package/build/ExpoAudioStream.web.d.ts +37 -0
- package/build/ExpoAudioStream.web.d.ts.map +1 -1
- package/build/ExpoAudioStream.web.js +478 -62
- package/build/ExpoAudioStream.web.js.map +1 -1
- package/build/ExpoAudioStreamModule.d.ts.map +1 -1
- package/build/ExpoAudioStreamModule.js +20 -0
- package/build/ExpoAudioStreamModule.js.map +1 -1
- package/build/WebRecorder.web.d.ts +74 -11
- package/build/WebRecorder.web.d.ts.map +1 -1
- package/build/WebRecorder.web.js +390 -74
- package/build/WebRecorder.web.js.map +1 -1
- package/build/hooks/useAudioDevices.d.ts +14 -0
- package/build/hooks/useAudioDevices.d.ts.map +1 -0
- package/build/hooks/useAudioDevices.js +151 -0
- package/build/hooks/useAudioDevices.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -0
- package/build/index.js.map +1 -1
- package/build/useAudioRecorder.d.ts +1 -0
- package/build/useAudioRecorder.d.ts.map +1 -1
- package/build/useAudioRecorder.js +20 -1
- package/build/useAudioRecorder.js.map +1 -1
- package/build/utils/BlobFix.d.ts.map +1 -1
- package/build/utils/BlobFix.js +2 -2
- package/build/utils/BlobFix.js.map +1 -1
- package/build/utils/writeWavHeader.d.ts +3 -18
- package/build/utils/writeWavHeader.d.ts.map +1 -1
- package/build/utils/writeWavHeader.js +19 -26
- package/build/utils/writeWavHeader.js.map +1 -1
- package/build/workers/InlineFeaturesExtractor.web.d.ts +1 -1
- package/build/workers/InlineFeaturesExtractor.web.d.ts.map +1 -1
- package/build/workers/InlineFeaturesExtractor.web.js +27 -26
- package/build/workers/InlineFeaturesExtractor.web.js.map +1 -1
- package/build/workers/inlineAudioWebWorker.web.d.ts +1 -1
- package/build/workers/inlineAudioWebWorker.web.d.ts.map +1 -1
- package/build/workers/inlineAudioWebWorker.web.js +25 -1
- package/build/workers/inlineAudioWebWorker.web.js.map +1 -1
- package/ios/AudioDeviceManager.swift +654 -0
- package/ios/AudioStreamManager.swift +964 -760
- package/ios/ExpoAudioStreamModule.swift +174 -19
- package/ios/Features.swift +1 -1
- package/ios/ISSUE_IOS.md +45 -0
- package/ios/Logger.swift +13 -1
- package/ios/RecordingSettings.swift +12 -0
- package/package.json +2 -2
- package/src/AudioAnalysis/AudioAnalysis.types.ts +2 -2
- package/src/AudioDeviceManager.ts +571 -0
- package/src/AudioRecorder.provider.tsx +3 -0
- package/src/ExpoAudioStream.types.ts +113 -1
- package/src/ExpoAudioStream.web.ts +609 -69
- package/src/ExpoAudioStreamModule.ts +23 -0
- package/src/WebRecorder.web.ts +482 -92
- package/src/hooks/useAudioDevices.ts +180 -0
- package/src/index.ts +6 -0
- package/src/types/crc-32.d.ts +6 -6
- package/src/useAudioRecorder.tsx +27 -1
- package/src/utils/BlobFix.ts +6 -4
- package/src/utils/writeWavHeader.ts +26 -25
- package/src/workers/InlineFeaturesExtractor.web.tsx +27 -26
- package/src/workers/inlineAudioWebWorker.web.tsx +25 -1
|
@@ -8,7 +8,7 @@ interface AudioFeaturesEvent {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
export declare class WebRecorder {
|
|
11
|
-
|
|
11
|
+
audioContext: AudioContext;
|
|
12
12
|
private audioWorkletNode;
|
|
13
13
|
private featureExtractorWorker?;
|
|
14
14
|
private source;
|
|
@@ -20,14 +20,27 @@ export declare class WebRecorder {
|
|
|
20
20
|
private bitDepth;
|
|
21
21
|
private exportBitDepth;
|
|
22
22
|
private audioAnalysisData;
|
|
23
|
-
private packetCount;
|
|
24
23
|
private logger?;
|
|
25
24
|
private compressedMediaRecorder;
|
|
26
25
|
private compressedChunks;
|
|
27
26
|
private compressedSize;
|
|
28
27
|
private pendingCompressedChunk;
|
|
29
|
-
private readonly wavMimeType;
|
|
30
28
|
private dataPointIdCounter;
|
|
29
|
+
private deviceDisconnectionHandler;
|
|
30
|
+
private mediaStream;
|
|
31
|
+
private onInterruptionCallback?;
|
|
32
|
+
private _isDeviceDisconnected;
|
|
33
|
+
private pcmData;
|
|
34
|
+
private totalSampleCount;
|
|
35
|
+
/**
|
|
36
|
+
* Flag to indicate whether this is the first audio chunk after a device switch
|
|
37
|
+
* Used to maintain proper duration counting
|
|
38
|
+
*/
|
|
39
|
+
isFirstChunkAfterSwitch: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Gets whether the recording device has been disconnected
|
|
42
|
+
*/
|
|
43
|
+
get isDeviceDisconnected(): boolean;
|
|
31
44
|
/**
|
|
32
45
|
* Initializes a new WebRecorder instance for audio recording and processing
|
|
33
46
|
* @param audioContext - The AudioContext to use for recording
|
|
@@ -35,14 +48,20 @@ export declare class WebRecorder {
|
|
|
35
48
|
* @param recordingConfig - Configuration options for the recording
|
|
36
49
|
* @param emitAudioEventCallback - Callback function for audio data events
|
|
37
50
|
* @param emitAudioAnalysisCallback - Callback function for audio analysis events
|
|
51
|
+
* @param onInterruption - Callback for recording interruptions
|
|
38
52
|
* @param logger - Optional logger for debugging information
|
|
39
53
|
*/
|
|
40
|
-
constructor({ audioContext, source, recordingConfig, emitAudioEventCallback, emitAudioAnalysisCallback, logger, }: {
|
|
54
|
+
constructor({ audioContext, source, recordingConfig, emitAudioEventCallback, emitAudioAnalysisCallback, onInterruption, logger, }: {
|
|
41
55
|
audioContext: AudioContext;
|
|
42
56
|
source: MediaStreamAudioSourceNode;
|
|
43
57
|
recordingConfig: RecordingConfig;
|
|
44
58
|
emitAudioEventCallback: EmitAudioEventFunction;
|
|
45
59
|
emitAudioAnalysisCallback: EmitAudioAnalysisFunction;
|
|
60
|
+
onInterruption?: (event: {
|
|
61
|
+
reason: string;
|
|
62
|
+
isPaused: boolean;
|
|
63
|
+
timestamp: number;
|
|
64
|
+
}) => void;
|
|
46
65
|
logger?: ConsoleLike;
|
|
47
66
|
});
|
|
48
67
|
/**
|
|
@@ -50,6 +69,11 @@ export declare class WebRecorder {
|
|
|
50
69
|
* Creates and connects the audio processing pipeline
|
|
51
70
|
*/
|
|
52
71
|
init(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Append new PCM data to the existing buffer
|
|
74
|
+
* @param newData New Float32Array data to append
|
|
75
|
+
*/
|
|
76
|
+
private appendPcmData;
|
|
53
77
|
/**
|
|
54
78
|
* Initializes the feature extractor worker for audio analysis
|
|
55
79
|
* Creates an inline worker from a blob for audio feature extraction
|
|
@@ -62,28 +86,43 @@ export declare class WebRecorder {
|
|
|
62
86
|
*/
|
|
63
87
|
handleFeatureExtractorMessage(event: AudioFeaturesEvent): void;
|
|
64
88
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
89
|
+
* Reset the data point counter to a specific value or zero
|
|
90
|
+
* @param startCounterFrom Optional value to start the counter from (for continuing from previous recordings)
|
|
67
91
|
*/
|
|
68
|
-
resetDataPointCounter(): void;
|
|
92
|
+
resetDataPointCounter(startCounterFrom?: number): void;
|
|
93
|
+
/**
|
|
94
|
+
* Get the current data point counter value
|
|
95
|
+
* @returns The current value of the data point counter
|
|
96
|
+
*/
|
|
97
|
+
getDataPointCounter(): number;
|
|
98
|
+
/**
|
|
99
|
+
* Prepares the recorder for continuity after device switch
|
|
100
|
+
* Sets up all necessary state to maintain proper recording continuity
|
|
101
|
+
*/
|
|
102
|
+
prepareForDeviceSwitch(): void;
|
|
69
103
|
/**
|
|
70
104
|
* Starts the audio recording process
|
|
71
105
|
* Connects the audio nodes and begins capturing audio data
|
|
106
|
+
* @param preserveCounters If true, do not reset the counter (used for device switching)
|
|
107
|
+
*/
|
|
108
|
+
start(preserveCounters?: boolean): void;
|
|
109
|
+
/**
|
|
110
|
+
* Creates a WAV file from the stored PCM data
|
|
72
111
|
*/
|
|
73
|
-
|
|
112
|
+
private createWavFromPcmData;
|
|
74
113
|
/**
|
|
75
114
|
* Stops the audio recording process and returns the recorded data
|
|
76
|
-
* @returns Promise resolving to an object containing
|
|
115
|
+
* @returns Promise resolving to an object containing compressed and/or uncompressed blobs
|
|
77
116
|
*/
|
|
78
117
|
stop(): Promise<{
|
|
79
|
-
pcmData: Float32Array;
|
|
80
118
|
compressedBlob?: Blob;
|
|
119
|
+
uncompressedBlob?: Blob;
|
|
81
120
|
}>;
|
|
82
121
|
/**
|
|
83
122
|
* Cleans up resources when recording is stopped
|
|
84
123
|
* Closes audio context and disconnects nodes
|
|
85
124
|
*/
|
|
86
|
-
|
|
125
|
+
cleanup(): void;
|
|
87
126
|
/**
|
|
88
127
|
* Pauses the audio recording process
|
|
89
128
|
* Disconnects audio nodes and pauses the media recorder
|
|
@@ -114,6 +153,30 @@ export declare class WebRecorder {
|
|
|
114
153
|
* Processes features if enabled
|
|
115
154
|
*/
|
|
116
155
|
processFeatures(chunk: Float32Array, sampleRate: number, chunkPosition: number, startPosition: number, endPosition: number, samples: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* Sets up detection for device disconnection events
|
|
158
|
+
*/
|
|
159
|
+
private setupDeviceDisconnectionDetection;
|
|
160
|
+
/**
|
|
161
|
+
* Explicitly set the position for continuous recording across device switches
|
|
162
|
+
* @param position The position in seconds to continue from
|
|
163
|
+
*/
|
|
164
|
+
setPosition(position: number): void;
|
|
165
|
+
/**
|
|
166
|
+
* Get the current position in seconds
|
|
167
|
+
* @returns The current position
|
|
168
|
+
*/
|
|
169
|
+
getPosition(): number;
|
|
170
|
+
/**
|
|
171
|
+
* Gets the current compressed chunks
|
|
172
|
+
* @returns Array of current compressed audio chunks
|
|
173
|
+
*/
|
|
174
|
+
getCompressedChunks(): Blob[];
|
|
175
|
+
/**
|
|
176
|
+
* Sets the compressed chunks from a previous recorder
|
|
177
|
+
* @param chunks Array of compressed chunks from a previous recorder
|
|
178
|
+
*/
|
|
179
|
+
setCompressedChunks(chunks: Blob[]): void;
|
|
117
180
|
}
|
|
118
181
|
export {};
|
|
119
182
|
//# sourceMappingURL=WebRecorder.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebRecorder.web.d.ts","sourceRoot":"","sources":["../src/WebRecorder.web.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EACH,yBAAyB,EACzB,sBAAsB,EACzB,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"WebRecorder.web.d.ts","sourceRoot":"","sources":["../src/WebRecorder.web.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