react-native-audio-api 0.9.0-nightly-96a5bcd-20251007 → 0.9.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/android/src/main/cpp/audioapi/android/core/{utils/AudioDecoder.cpp → AudioDecoder.cpp} +75 -79
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +43 -99
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +101 -1
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +3 -0
- package/common/cpp/audioapi/core/AudioContext.cpp +2 -0
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +35 -0
- package/common/cpp/audioapi/core/BaseAudioContext.h +12 -4
- package/common/cpp/audioapi/core/OfflineAudioContext.cpp +2 -0
- package/common/cpp/audioapi/core/utils/AudioDecoder.h +90 -36
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +282 -241
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.h +19 -57
- package/common/cpp/test/CMakeLists.txt +1 -1
- package/ios/audioapi/ios/core/AudioDecoder.mm +156 -0
- package/lib/commonjs/api.js +1 -14
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +18 -11
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/module/api.js +1 -2
- package/lib/module/api.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +18 -11
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +1 -3
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +6 -3
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +3 -6
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +0 -5
- package/src/core/BaseAudioContext.ts +29 -26
- package/src/interfaces.ts +6 -18
- package/common/cpp/audioapi/HostObjects/utils/AudioDecoderHostObject.cpp +0 -107
- package/common/cpp/audioapi/HostObjects/utils/AudioDecoderHostObject.h +0 -28
- package/common/cpp/audioapi/core/types/AudioFormat.h +0 -16
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +0 -160
- package/lib/commonjs/core/AudioDecoder.js +0 -48
- package/lib/commonjs/core/AudioDecoder.js.map +0 -1
- package/lib/module/core/AudioDecoder.js +0 -42
- package/lib/module/core/AudioDecoder.js.map +0 -1
- package/lib/typescript/core/AudioDecoder.d.ts +0 -4
- package/lib/typescript/core/AudioDecoder.d.ts.map +0 -1
- package/src/core/AudioDecoder.ts +0 -78
package/src/core/AudioDecoder.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { IAudioDecoder } from '../interfaces';
|
|
2
|
-
import AudioBuffer from './AudioBuffer';
|
|
3
|
-
|
|
4
|
-
class AudioDecoder {
|
|
5
|
-
private static instance: AudioDecoder | null = null;
|
|
6
|
-
protected readonly decoder: IAudioDecoder;
|
|
7
|
-
|
|
8
|
-
private constructor() {
|
|
9
|
-
this.decoder = global.createAudioDecoder();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public static getInstance(): AudioDecoder {
|
|
13
|
-
if (!AudioDecoder.instance) {
|
|
14
|
-
AudioDecoder.instance = new AudioDecoder();
|
|
15
|
-
}
|
|
16
|
-
return AudioDecoder.instance;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public async decodeAudioDataInstance(
|
|
20
|
-
input: string | ArrayBuffer,
|
|
21
|
-
sampleRate?: number
|
|
22
|
-
): Promise<AudioBuffer> {
|
|
23
|
-
let buffer;
|
|
24
|
-
if (typeof input === 'string') {
|
|
25
|
-
// Remove the file:// prefix if it exists
|
|
26
|
-
if (input.startsWith('file://')) {
|
|
27
|
-
input = input.replace('file://', '');
|
|
28
|
-
}
|
|
29
|
-
buffer = await this.decoder.decodeWithFilePath(input, sampleRate ?? 0);
|
|
30
|
-
} else if (input instanceof ArrayBuffer) {
|
|
31
|
-
buffer = await this.decoder.decodeWithMemoryBlock(
|
|
32
|
-
new Uint8Array(input),
|
|
33
|
-
sampleRate ?? 0
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!buffer) {
|
|
38
|
-
throw new Error('Unsupported input type or failed to decode audio');
|
|
39
|
-
}
|
|
40
|
-
return new AudioBuffer(buffer);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public async decodePCMInBase64Instance(
|
|
44
|
-
base64String: string,
|
|
45
|
-
inputSampleRate: number,
|
|
46
|
-
inputChannelCount: number,
|
|
47
|
-
interleaved: boolean
|
|
48
|
-
): Promise<AudioBuffer> {
|
|
49
|
-
const buffer = await this.decoder.decodeWithPCMInBase64(
|
|
50
|
-
base64String,
|
|
51
|
-
inputSampleRate,
|
|
52
|
-
inputChannelCount,
|
|
53
|
-
interleaved
|
|
54
|
-
);
|
|
55
|
-
return new AudioBuffer(buffer);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export async function decodeAudioData(
|
|
60
|
-
input: string | ArrayBuffer,
|
|
61
|
-
sampleRate?: number
|
|
62
|
-
): Promise<AudioBuffer> {
|
|
63
|
-
return AudioDecoder.getInstance().decodeAudioDataInstance(input, sampleRate);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export async function decodePCMInBase64(
|
|
67
|
-
base64String: string,
|
|
68
|
-
inputSampleRate: number,
|
|
69
|
-
inputChannelCount: number,
|
|
70
|
-
isInterleaved: boolean = true
|
|
71
|
-
): Promise<AudioBuffer> {
|
|
72
|
-
return AudioDecoder.getInstance().decodePCMInBase64Instance(
|
|
73
|
-
base64String,
|
|
74
|
-
inputSampleRate,
|
|
75
|
-
inputChannelCount,
|
|
76
|
-
isInterleaved
|
|
77
|
-
);
|
|
78
|
-
}
|