@siteed/expo-audio-studio 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +210 -0
- package/LICENSE +21 -0
- package/README.md +269 -0
- package/android/build.gradle +105 -0
- package/android/src/main/AndroidManifest.xml +27 -0
- package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +166 -0
- package/android/src/main/java/net/siteed/audiostream/AudioDataEncoder.kt +9 -0
- package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +131 -0
- package/android/src/main/java/net/siteed/audiostream/AudioFormatUtils.kt +103 -0
- package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +435 -0
- package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +2235 -0
- package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +1437 -0
- package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +166 -0
- package/android/src/main/java/net/siteed/audiostream/AudioTrimmer.kt +1099 -0
- package/android/src/main/java/net/siteed/audiostream/Constants.kt +21 -0
- package/android/src/main/java/net/siteed/audiostream/EventSender.kt +7 -0
- package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +739 -0
- package/android/src/main/java/net/siteed/audiostream/FFT.kt +99 -0
- package/android/src/main/java/net/siteed/audiostream/Features.kt +98 -0
- package/android/src/main/java/net/siteed/audiostream/NotificationConfig.kt +70 -0
- package/android/src/main/java/net/siteed/audiostream/PermissionUtils.kt +59 -0
- package/android/src/main/java/net/siteed/audiostream/RecordingActionReceiver.kt +59 -0
- package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +205 -0
- package/android/src/main/java/net/siteed/audiostream/WaveformConfig.kt +19 -0
- package/android/src/main/java/net/siteed/audiostream/WaveformRenderer.kt +159 -0
- package/android/src/main/res/drawable/ic_default_action_icon.xml +16 -0
- package/android/src/main/res/drawable/ic_microphone.xml +13 -0
- package/android/src/main/res/drawable/ic_pause.xml +10 -0
- package/android/src/main/res/drawable/ic_play.xml +10 -0
- package/android/src/main/res/drawable/ic_stop.xml +10 -0
- package/android/src/main/res/layout/notification_recording.xml +37 -0
- package/android/src/main/test/java/net/siteed/audiostream/AudioProcessorTest.kt +56 -0
- package/app.plugin.js +1 -0
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts +179 -0
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -0
- package/build/AudioAnalysis/AudioAnalysis.types.js +3 -0
- package/build/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts +68 -0
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -0
- package/build/AudioAnalysis/extractAudioAnalysis.js +203 -0
- package/build/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
- package/build/AudioAnalysis/extractAudioData.d.ts +3 -0
- package/build/AudioAnalysis/extractAudioData.d.ts.map +1 -0
- package/build/AudioAnalysis/extractAudioData.js +5 -0
- package/build/AudioAnalysis/extractAudioData.js.map +1 -0
- package/build/AudioAnalysis/extractMelSpectrogram.d.ts +14 -0
- package/build/AudioAnalysis/extractMelSpectrogram.d.ts.map +1 -0
- package/build/AudioAnalysis/extractMelSpectrogram.js +85 -0
- package/build/AudioAnalysis/extractMelSpectrogram.js.map +1 -0
- package/build/AudioAnalysis/extractPreview.d.ts +11 -0
- package/build/AudioAnalysis/extractPreview.d.ts.map +1 -0
- package/build/AudioAnalysis/extractPreview.js +25 -0
- package/build/AudioAnalysis/extractPreview.js.map +1 -0
- package/build/AudioAnalysis/extractWaveform.d.ts +8 -0
- package/build/AudioAnalysis/extractWaveform.d.ts.map +1 -0
- package/build/AudioAnalysis/extractWaveform.js +11 -0
- package/build/AudioAnalysis/extractWaveform.js.map +1 -0
- package/build/AudioRecorder.provider.d.ts +11 -0
- package/build/AudioRecorder.provider.d.ts.map +1 -0
- package/build/AudioRecorder.provider.js +37 -0
- package/build/AudioRecorder.provider.js.map +1 -0
- package/build/ExpoAudioStream.native.d.ts +3 -0
- package/build/ExpoAudioStream.native.d.ts.map +1 -0
- package/build/ExpoAudioStream.native.js +6 -0
- package/build/ExpoAudioStream.native.js.map +1 -0
- package/build/ExpoAudioStream.types.d.ts +532 -0
- package/build/ExpoAudioStream.types.d.ts.map +1 -0
- package/build/ExpoAudioStream.types.js +2 -0
- package/build/ExpoAudioStream.types.js.map +1 -0
- package/build/ExpoAudioStream.web.d.ts +59 -0
- package/build/ExpoAudioStream.web.d.ts.map +1 -0
- package/build/ExpoAudioStream.web.js +285 -0
- package/build/ExpoAudioStream.web.js.map +1 -0
- package/build/ExpoAudioStreamModule.d.ts +3 -0
- package/build/ExpoAudioStreamModule.d.ts.map +1 -0
- package/build/ExpoAudioStreamModule.js +693 -0
- package/build/ExpoAudioStreamModule.js.map +1 -0
- package/build/WebRecorder.web.d.ts +119 -0
- package/build/WebRecorder.web.d.ts.map +1 -0
- package/build/WebRecorder.web.js +436 -0
- package/build/WebRecorder.web.js.map +1 -0
- package/build/constants.d.ts +11 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +14 -0
- package/build/constants.js.map +1 -0
- package/build/events.d.ts +26 -0
- package/build/events.d.ts.map +1 -0
- package/build/events.js +21 -0
- package/build/events.js.map +1 -0
- package/build/index.d.ts +15 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +14 -0
- package/build/index.js.map +1 -0
- package/build/trimAudio.d.ts +25 -0
- package/build/trimAudio.d.ts.map +1 -0
- package/build/trimAudio.js +67 -0
- package/build/trimAudio.js.map +1 -0
- package/build/useAudioRecorder.d.ts +21 -0
- package/build/useAudioRecorder.d.ts.map +1 -0
- package/build/useAudioRecorder.js +427 -0
- package/build/useAudioRecorder.js.map +1 -0
- package/build/utils/BlobFix.d.ts +9 -0
- package/build/utils/BlobFix.d.ts.map +1 -0
- package/build/utils/BlobFix.js +498 -0
- package/build/utils/BlobFix.js.map +1 -0
- package/build/utils/audioProcessing.d.ts +24 -0
- package/build/utils/audioProcessing.d.ts.map +1 -0
- package/build/utils/audioProcessing.js +133 -0
- package/build/utils/audioProcessing.js.map +1 -0
- package/build/utils/concatenateBuffers.d.ts +8 -0
- package/build/utils/concatenateBuffers.d.ts.map +1 -0
- package/build/utils/concatenateBuffers.js +21 -0
- package/build/utils/concatenateBuffers.js.map +1 -0
- package/build/utils/convertPCMToFloat32.d.ts +13 -0
- package/build/utils/convertPCMToFloat32.d.ts.map +1 -0
- package/build/utils/convertPCMToFloat32.js +120 -0
- package/build/utils/convertPCMToFloat32.js.map +1 -0
- package/build/utils/encodingToBitDepth.d.ts +5 -0
- package/build/utils/encodingToBitDepth.d.ts.map +1 -0
- package/build/utils/encodingToBitDepth.js +13 -0
- package/build/utils/encodingToBitDepth.js.map +1 -0
- package/build/utils/getWavFileInfo.d.ts +26 -0
- package/build/utils/getWavFileInfo.d.ts.map +1 -0
- package/build/utils/getWavFileInfo.js +92 -0
- package/build/utils/getWavFileInfo.js.map +1 -0
- package/build/utils/writeWavHeader.d.ts +49 -0
- package/build/utils/writeWavHeader.d.ts.map +1 -0
- package/build/utils/writeWavHeader.js +91 -0
- package/build/utils/writeWavHeader.js.map +1 -0
- package/build/workers/InlineFeaturesExtractor.web.d.ts +2 -0
- package/build/workers/InlineFeaturesExtractor.web.d.ts.map +1 -0
- package/build/workers/InlineFeaturesExtractor.web.js +828 -0
- package/build/workers/InlineFeaturesExtractor.web.js.map +1 -0
- package/build/workers/inlineAudioWebWorker.web.d.ts +2 -0
- package/build/workers/inlineAudioWebWorker.web.d.ts.map +1 -0
- package/build/workers/inlineAudioWebWorker.web.js +157 -0
- package/build/workers/inlineAudioWebWorker.web.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/AudioAnalysisData.swift +74 -0
- package/ios/AudioNotificationManager.swift +135 -0
- package/ios/AudioProcessingHelpers.swift +743 -0
- package/ios/AudioProcessor.swift +1313 -0
- package/ios/AudioStreamError.swift +7 -0
- package/ios/AudioStreamManager.swift +1708 -0
- package/ios/AudioStreamManagerDelegate.swift +16 -0
- package/ios/DataPoint.swift +54 -0
- package/ios/DecodingConfig.swift +47 -0
- package/ios/ExpoAudioStream.podspec +27 -0
- package/ios/ExpoAudioStreamModule.swift +805 -0
- package/ios/FFT.swift +62 -0
- package/ios/Features.swift +95 -0
- package/ios/Logger.swift +7 -0
- package/ios/NotificationExtension.swift +15 -0
- package/ios/RecordingResult.swift +22 -0
- package/ios/RecordingSettings.swift +265 -0
- package/ios/WaveformExtractor.swift +105 -0
- package/package.json +128 -0
- package/plugin/build/index.d.ts +21 -0
- package/plugin/build/index.js +192 -0
- package/plugin/src/index.ts +279 -0
- package/plugin/tsconfig.json +10 -0
- package/plugin/tsconfig.tsbuildinfo +1 -0
- package/src/AudioAnalysis/AudioAnalysis.types.ts +202 -0
- package/src/AudioAnalysis/extractAudioAnalysis.ts +333 -0
- package/src/AudioAnalysis/extractAudioData.ts +6 -0
- package/src/AudioAnalysis/extractMelSpectrogram.ts +144 -0
- package/src/AudioAnalysis/extractPreview.ts +34 -0
- package/src/AudioAnalysis/extractWaveform.ts +22 -0
- package/src/AudioRecorder.provider.tsx +54 -0
- package/src/ExpoAudioStream.native.ts +6 -0
- package/src/ExpoAudioStream.types.ts +641 -0
- package/src/ExpoAudioStream.web.ts +359 -0
- package/src/ExpoAudioStreamModule.ts +967 -0
- package/src/WebRecorder.web.ts +580 -0
- package/src/constants.ts +18 -0
- package/src/events.ts +60 -0
- package/src/index.ts +36 -0
- package/src/trimAudio.ts +90 -0
- package/src/useAudioRecorder.tsx +620 -0
- package/src/utils/BlobFix.ts +559 -0
- package/src/utils/audioProcessing.ts +205 -0
- package/src/utils/concatenateBuffers.ts +24 -0
- package/src/utils/convertPCMToFloat32.ts +170 -0
- package/src/utils/encodingToBitDepth.ts +18 -0
- package/src/utils/getWavFileInfo.ts +132 -0
- package/src/utils/writeWavHeader.ts +114 -0
- package/src/workers/InlineFeaturesExtractor.web.tsx +827 -0
- package/src/workers/inlineAudioWebWorker.web.tsx +156 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PreviewOptions, AudioAnalysis } from './AudioAnalysis.types'
|
|
2
|
+
import { extractAudioAnalysis } from './extractAudioAnalysis'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generates a simplified preview of the audio waveform for quick visualization.
|
|
6
|
+
* Ideal for UI rendering with a specified number of points.
|
|
7
|
+
*
|
|
8
|
+
* @param options - The options for the preview, including file URI and time range.
|
|
9
|
+
* @returns A promise that resolves to the audio preview data.
|
|
10
|
+
*/
|
|
11
|
+
export async function extractPreview({
|
|
12
|
+
fileUri,
|
|
13
|
+
numberOfPoints = 100,
|
|
14
|
+
startTimeMs = 0,
|
|
15
|
+
endTimeMs = 30000, // First 30 seconds
|
|
16
|
+
decodingOptions,
|
|
17
|
+
logger,
|
|
18
|
+
}: PreviewOptions): Promise<AudioAnalysis> {
|
|
19
|
+
const durationMs = endTimeMs - startTimeMs
|
|
20
|
+
const segmentDurationMs = Math.floor(durationMs / numberOfPoints)
|
|
21
|
+
|
|
22
|
+
// Call extractAudioAnalysis with calculated parameters
|
|
23
|
+
const analysis = await extractAudioAnalysis({
|
|
24
|
+
fileUri,
|
|
25
|
+
startTimeMs,
|
|
26
|
+
endTimeMs,
|
|
27
|
+
logger,
|
|
28
|
+
segmentDurationMs,
|
|
29
|
+
decodingOptions,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Transform the result into AudioPreview format
|
|
33
|
+
return analysis
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import ExpoAudioStreamModule from '../ExpoAudioStreamModule'
|
|
2
|
+
|
|
3
|
+
export interface ExtractWaveformProps {
|
|
4
|
+
fileUri: string
|
|
5
|
+
numberOfSamples: number
|
|
6
|
+
offset?: number
|
|
7
|
+
length?: number
|
|
8
|
+
}
|
|
9
|
+
export const extractWaveform = async ({
|
|
10
|
+
fileUri,
|
|
11
|
+
numberOfSamples,
|
|
12
|
+
offset = 0,
|
|
13
|
+
length,
|
|
14
|
+
}: ExtractWaveformProps): Promise<unknown> => {
|
|
15
|
+
const res = await ExpoAudioStreamModule.extractAudioAnalysis({
|
|
16
|
+
fileUri,
|
|
17
|
+
numberOfSamples,
|
|
18
|
+
offset,
|
|
19
|
+
length,
|
|
20
|
+
})
|
|
21
|
+
return res
|
|
22
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// packages/expo-audio-stream/src/AudioRecorder.provider.tsx
|
|
2
|
+
import React, { createContext, useContext } from 'react'
|
|
3
|
+
|
|
4
|
+
import { UseAudioRecorderState } from './ExpoAudioStream.types'
|
|
5
|
+
import { UseAudioRecorderProps, useAudioRecorder } from './useAudioRecorder'
|
|
6
|
+
|
|
7
|
+
const initContext: UseAudioRecorderState = {
|
|
8
|
+
isRecording: false,
|
|
9
|
+
isPaused: false,
|
|
10
|
+
durationMs: 0,
|
|
11
|
+
size: 0,
|
|
12
|
+
compression: undefined,
|
|
13
|
+
startRecording: async () => {
|
|
14
|
+
throw new Error('AudioRecorderProvider not found')
|
|
15
|
+
},
|
|
16
|
+
stopRecording: async () => {
|
|
17
|
+
throw new Error('AudioRecorderProvider not found')
|
|
18
|
+
},
|
|
19
|
+
pauseRecording: async () => {
|
|
20
|
+
throw new Error('AudioRecorderProvider not found')
|
|
21
|
+
},
|
|
22
|
+
resumeRecording: async () => {
|
|
23
|
+
throw new Error('AudioRecorderProvider not found')
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const AudioRecorderContext = createContext<UseAudioRecorderState>(initContext)
|
|
28
|
+
|
|
29
|
+
interface AudioRecorderProviderProps {
|
|
30
|
+
children: React.ReactNode
|
|
31
|
+
config?: UseAudioRecorderProps
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const AudioRecorderProvider: React.FC<AudioRecorderProviderProps> = ({
|
|
35
|
+
children,
|
|
36
|
+
config = {},
|
|
37
|
+
}) => {
|
|
38
|
+
const audioRecorder = useAudioRecorder(config)
|
|
39
|
+
return (
|
|
40
|
+
<AudioRecorderContext.Provider value={audioRecorder}>
|
|
41
|
+
{children}
|
|
42
|
+
</AudioRecorderContext.Provider>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const useSharedAudioRecorder = () => {
|
|
47
|
+
const context = useContext(AudioRecorderContext)
|
|
48
|
+
if (!context) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
'useSharedAudioRecorder must be used within an AudioRecorderProvider'
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
return context
|
|
54
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// src/ExpoAudioStreamModule.ts
|
|
2
|
+
import { requireNativeModule } from 'expo-modules-core'
|
|
3
|
+
|
|
4
|
+
// It loads the native module object from the JSI or falls back to
|
|
5
|
+
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
|
|
6
|
+
export default requireNativeModule('ExpoAudioStream')
|