react-native-tiny-wavpack-decoder 0.1.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/LICENSE +20 -0
- package/README.md +148 -0
- package/android/build.gradle +112 -0
- package/android/generated/java/com/tinywavpackdecoder/NativeTinyWavPackDecoderSpec.java +47 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNTinyWavPackDecoderSpec-generated.cpp +44 -0
- package/android/generated/jni/RNTinyWavPackDecoderSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNTinyWavPackDecoderSpec/RNTinyWavPackDecoderSpecJSI-generated.cpp +46 -0
- package/android/generated/jni/react/renderer/components/RNTinyWavPackDecoderSpec/RNTinyWavPackDecoderSpecJSI.h +89 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/cpp/CMakeLists.txt +54 -0
- package/android/src/main/cpp/TinyWavPackDecoderModule.cpp +118 -0
- package/android/src/main/java/com/tinywavpackdecoder/TinyWavPackDecoderModule.kt +114 -0
- package/android/src/main/java/com/tinywavpackdecoder/TinyWavPackDecoderPackage.kt +18 -0
- package/ios/TinyWavPackDecoder.h +8 -0
- package/ios/TinyWavPackDecoder.mm +83 -0
- package/ios/generated/RNTinyWavPackDecoderSpec/RNTinyWavPackDecoderSpec-generated.mm +53 -0
- package/ios/generated/RNTinyWavPackDecoderSpec/RNTinyWavPackDecoderSpec.h +69 -0
- package/ios/generated/RNTinyWavPackDecoderSpecJSI-generated.cpp +46 -0
- package/ios/generated/RNTinyWavPackDecoderSpecJSI.h +89 -0
- package/lib/module/NativeTinyWavPackDecoder.ts +19 -0
- package/lib/module/index.js +38 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/tiny-wavpack/common/TinyWavPackDecoderInterface.c +414 -0
- package/lib/module/tiny-wavpack/common/TinyWavPackDecoderInterface.h +52 -0
- package/lib/module/tiny-wavpack/common/test.c +45 -0
- package/lib/module/tiny-wavpack/common/wv2wav +0 -0
- package/lib/module/tiny-wavpack/lib/bits.c +140 -0
- package/lib/module/tiny-wavpack/lib/float.c +50 -0
- package/lib/module/tiny-wavpack/lib/license.txt +25 -0
- package/lib/module/tiny-wavpack/lib/metadata.c +105 -0
- package/lib/module/tiny-wavpack/lib/readme.txt +68 -0
- package/lib/module/tiny-wavpack/lib/unpack.c +785 -0
- package/lib/module/tiny-wavpack/lib/wavpack.h +384 -0
- package/lib/module/tiny-wavpack/lib/words.c +560 -0
- package/lib/module/tiny-wavpack/lib/wputils.c +351 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeTinyWavPackDecoder.d.ts +9 -0
- package/lib/typescript/src/NativeTinyWavPackDecoder.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +195 -0
- package/react-native-wavpack-decoder.podspec +35 -0
- package/react-native.config.js +12 -0
- package/src/NativeTinyWavPackDecoder.ts +19 -0
- package/src/index.tsx +57 -0
- package/src/tiny-wavpack/common/TinyWavPackDecoderInterface.c +414 -0
- package/src/tiny-wavpack/common/TinyWavPackDecoderInterface.h +52 -0
- package/src/tiny-wavpack/common/test.c +45 -0
- package/src/tiny-wavpack/common/wv2wav +0 -0
- package/src/tiny-wavpack/lib/bits.c +140 -0
- package/src/tiny-wavpack/lib/float.c +50 -0
- package/src/tiny-wavpack/lib/license.txt +25 -0
- package/src/tiny-wavpack/lib/metadata.c +105 -0
- package/src/tiny-wavpack/lib/readme.txt +68 -0
- package/src/tiny-wavpack/lib/unpack.c +785 -0
- package/src/tiny-wavpack/lib/wavpack.h +384 -0
- package/src/tiny-wavpack/lib/words.c +560 -0
- package/src/tiny-wavpack/lib/wputils.c +351 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jairaj Jangle
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# react-native-tiny-wavpack-decoder
|
|
2
|
+
|
|
3
|
+
A lightweight React Native Turbo Module for decoding WavPack audio files to WAV format on iOS and Android. Built with the New Architecture for optimal performance, this module supports progress updates during decoding and is designed for seamless integration into React Native apps.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Decode WavPack (.wv) files to WAV format.
|
|
7
|
+
- Cross-platform support for iOS (13.0+) and Android (API 21+).
|
|
8
|
+
- Progress updates via event emitter for real-time feedback.
|
|
9
|
+
- Configurable decoding options (e.g., max samples, bits per sample.
|
|
10
|
+
- Thread-safe decoding on iOS with concurrent queue support.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
- React Native 0.75 or higher with New Architecture enabled.
|
|
14
|
+
- iOS 13.0 or later.
|
|
15
|
+
- Android API 21 or later.
|
|
16
|
+
- Node.js 16+ for development.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
1. **Install the package**:
|
|
21
|
+
|
|
22
|
+
Using yarn:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
yarn add react-native-tiny-wavpack-decoder
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
using npm:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install react-native-tiny-wavpack-decoder
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. **Link native dependencies**:
|
|
35
|
+
|
|
36
|
+
- For iOS, install CocoaPods dependencies:
|
|
37
|
+
```bash
|
|
38
|
+
cd ios && pod install
|
|
39
|
+
```
|
|
40
|
+
- For Android, the module is auto-linked via React Native.
|
|
41
|
+
|
|
42
|
+
3. **Enable New Architecture** (if not already enabled):
|
|
43
|
+
- In `ios/Podfile`, ensure:
|
|
44
|
+
```ruby
|
|
45
|
+
use_react_native!(
|
|
46
|
+
:path => '../node_modules/react-native',
|
|
47
|
+
:new_architecture => true
|
|
48
|
+
)
|
|
49
|
+
```
|
|
50
|
+
- In `android/app/build.gradle`, enable Turbo Modules:
|
|
51
|
+
```gradle
|
|
52
|
+
newArchEnabled=true
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
4. **Rebuild the app**:
|
|
56
|
+
```bash
|
|
57
|
+
npx react-native run-ios
|
|
58
|
+
# or
|
|
59
|
+
npx react-native run-android
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Basic Decoding
|
|
65
|
+
Decode a WavPack file to WAV using the `decode` method. The module requires file paths accessible by the app (e.g., in the document directory).
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import TinyWavPackDecoder from 'react-native-tiny-wavpack-decoder';
|
|
69
|
+
import * as RNFS from '@dr.pogodin/react-native-fs';
|
|
70
|
+
|
|
71
|
+
const decodeWavPack = async () => {
|
|
72
|
+
const inputPath = `${RNFS.DocumentDirectoryPath}/sample.wv`; // Ensure file exists
|
|
73
|
+
const outputPath = `${RNFS.DocumentDirectoryPath}/output.wav`;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const result = await TinyWavPackDecoder.decode(inputPath, outputPath, {
|
|
77
|
+
maxSamples: -1, // Decode all samples
|
|
78
|
+
bitsPerSample: 16, // Output bit depth (8, 16, 24, or 32)
|
|
79
|
+
});
|
|
80
|
+
console.log('Decode result:', result); // "Success"
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Decode error:', error.message);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Progress Updates
|
|
88
|
+
Subscribe to decoding progress events (0.0 to 1.0) using `addProgressListener`.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { useEffect } from 'react';
|
|
92
|
+
import TinyWavPackDecoder from 'react-native-tiny-wavpack-decoder';
|
|
93
|
+
|
|
94
|
+
const App = () => {
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const subscription = TinyWavPackDecoder.addProgressListener((progress) => {
|
|
97
|
+
console.log(`Progress: ${(progress * 100).toFixed(2)}%`);
|
|
98
|
+
});
|
|
99
|
+
return () => {
|
|
100
|
+
subscription.remove();
|
|
101
|
+
};
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
// Trigger decodeWavPack() as shown above
|
|
105
|
+
};
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Options
|
|
109
|
+
The `decode` method accepts an options object with the following properties:
|
|
110
|
+
|
|
111
|
+
| Option | Type | Default | Description |
|
|
112
|
+
|-----------------|--------------------------|---------|-----------------------------------------------------------------------------|
|
|
113
|
+
| `maxSamples` | `number` | `-1` | Maximum number of samples to decode. Use `-1` for all samples. |
|
|
114
|
+
| `bitsPerSample` | `8 | 16 | 24 | 32` | `16` | Output bit depth. Must be 8, 16, 24, or 32. |
|
|
115
|
+
|
|
116
|
+
### Example App
|
|
117
|
+
The `example/` directory contains a sample app demonstrating decoding and progress updates. To run it:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
cd example
|
|
121
|
+
npm install
|
|
122
|
+
npm run ios
|
|
123
|
+
# or
|
|
124
|
+
npm run android
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Place a `sample.wv` file in the app’s document directory (e.g., via `RNFS.DocumentDirectoryPath`).
|
|
128
|
+
|
|
129
|
+
## Notes
|
|
130
|
+
- **File Access**: Ensure input and output paths are valid and accessible. Use libraries like `@dr.pogodin/react-native-fs` to manage files.
|
|
131
|
+
- **Thread Safety**: iOS uses a concurrent dispatch queue for decoding, but rapid concurrent calls may require additional thread-safety measures (see Limitations).
|
|
132
|
+
- **Progress Events**: Ensure listeners are set up before starting decoding.
|
|
133
|
+
- **New Architecture**: This module requires Turbo Modules and the New Architecture. Ensure your app is configured accordingly.
|
|
134
|
+
|
|
135
|
+
## Limitations
|
|
136
|
+
- The module uses a static `FILE*` in the C code, which may cause crashes if multiple decoding operations are triggered concurrently. A thread-safe version is planned (see [issue #TBD]).
|
|
137
|
+
- Progress updates are tied to the decoding buffer size (4096 samples), which may result in coarse-grained updates for small files.
|
|
138
|
+
- Android performance may vary on low-end devices due to JNI overhead.
|
|
139
|
+
|
|
140
|
+
## Contributing
|
|
141
|
+
Contributions are welcome! Please open an issue or pull request on the [GitHub repository](https://github.com/JairajJangle/react-native-tiny-wavpack-decoder) for bugs, features, or improvements.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
145
|
+
|
|
146
|
+
## Acknowledgments
|
|
147
|
+
- Built with [WavPack](https://www.wavpack.com/)'s Tiny Decoder source for efficient audio decoding.
|
|
148
|
+
- Uses React Native’s New Architecture for modern performance.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['TinyWavPackDecoder_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
|
|
24
|
+
def getExtOrIntegerDefault(name) {
|
|
25
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["TinyWavPackDecoder_" + name]).toInteger()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def supportsNamespace() {
|
|
29
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
30
|
+
def major = parsed[0].toInteger()
|
|
31
|
+
def minor = parsed[1].toInteger()
|
|
32
|
+
|
|
33
|
+
// Namespace support was added in 7.3.0
|
|
34
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
android {
|
|
38
|
+
if (supportsNamespace()) {
|
|
39
|
+
namespace "com.tinywavpackdecoder"
|
|
40
|
+
|
|
41
|
+
sourceSets {
|
|
42
|
+
main {
|
|
43
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
49
|
+
|
|
50
|
+
defaultConfig {
|
|
51
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
52
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
53
|
+
|
|
54
|
+
externalNativeBuild {
|
|
55
|
+
cmake {
|
|
56
|
+
arguments "-DANDROID_STL=c++_shared"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
externalNativeBuild {
|
|
62
|
+
cmake {
|
|
63
|
+
path "src/main/cpp/CMakeLists.txt"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
buildFeatures {
|
|
68
|
+
buildConfig true
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
buildTypes {
|
|
72
|
+
release {
|
|
73
|
+
minifyEnabled false
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
lintOptions {
|
|
78
|
+
disable "GradleCompatible"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
compileOptions {
|
|
82
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
83
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
sourceSets {
|
|
87
|
+
main {
|
|
88
|
+
java.srcDirs += [
|
|
89
|
+
"generated/java",
|
|
90
|
+
"generated/jni"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
repositories {
|
|
97
|
+
mavenCentral()
|
|
98
|
+
google()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
102
|
+
|
|
103
|
+
dependencies {
|
|
104
|
+
implementation "com.facebook.react:react-android"
|
|
105
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
react {
|
|
109
|
+
jsRootDir = file("../src/")
|
|
110
|
+
libraryName = "TinyWavPackDecoder"
|
|
111
|
+
codegenJavaPackageName = "com.tinywavpackdecoder"
|
|
112
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.tinywavpackdecoder;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
21
|
+
import javax.annotation.Nonnull;
|
|
22
|
+
import javax.annotation.Nullable;
|
|
23
|
+
|
|
24
|
+
public abstract class NativeTinyWavPackDecoderSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
25
|
+
public static final String NAME = "TinyWavPackDecoderModule";
|
|
26
|
+
|
|
27
|
+
public NativeTinyWavPackDecoderSpec(ReactApplicationContext reactContext) {
|
|
28
|
+
super(reactContext);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public @Nonnull String getName() {
|
|
33
|
+
return NAME;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ReactMethod
|
|
37
|
+
@DoNotStrip
|
|
38
|
+
public abstract void decodeWavPack(String inputPath, String outputPath, @Nullable Double maxSamples, @Nullable Double bitsPerSample, Promise promise);
|
|
39
|
+
|
|
40
|
+
@ReactMethod
|
|
41
|
+
@DoNotStrip
|
|
42
|
+
public abstract void addListener(String eventType);
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
public abstract void removeListeners(double count);
|
|
47
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.13)
|
|
7
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
8
|
+
|
|
9
|
+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNTinyWavPackDecoderSpec/*.cpp)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
react_codegen_RNTinyWavPackDecoderSpec
|
|
13
|
+
OBJECT
|
|
14
|
+
${react_codegen_SRCS}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
target_include_directories(react_codegen_RNTinyWavPackDecoderSpec PUBLIC . react/renderer/components/RNTinyWavPackDecoderSpec)
|
|
18
|
+
|
|
19
|
+
target_link_libraries(
|
|
20
|
+
react_codegen_RNTinyWavPackDecoderSpec
|
|
21
|
+
fbjni
|
|
22
|
+
jsi
|
|
23
|
+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
|
|
24
|
+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
|
|
25
|
+
reactnative
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_compile_options(
|
|
29
|
+
react_codegen_RNTinyWavPackDecoderSpec
|
|
30
|
+
PRIVATE
|
|
31
|
+
-DLOG_TAG=\"ReactNative\"
|
|
32
|
+
-fexceptions
|
|
33
|
+
-frtti
|
|
34
|
+
-std=c++20
|
|
35
|
+
-Wall
|
|
36
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "RNTinyWavPackDecoderSpec.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeTinyWavPackDecoderSpecJSI_decodeWavPack(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "decodeWavPack", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeTinyWavPackDecoderSpecJSI_addListener(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "addListener", "(Ljava/lang/String;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static facebook::jsi::Value __hostFunction_NativeTinyWavPackDecoderSpecJSI_removeListeners(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
26
|
+
static jmethodID cachedMethodId = nullptr;
|
|
27
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "removeListeners", "(D)V", args, count, cachedMethodId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
NativeTinyWavPackDecoderSpecJSI::NativeTinyWavPackDecoderSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
31
|
+
: JavaTurboModule(params) {
|
|
32
|
+
methodMap_["decodeWavPack"] = MethodMetadata {4, __hostFunction_NativeTinyWavPackDecoderSpecJSI_decodeWavPack};
|
|
33
|
+
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeTinyWavPackDecoderSpecJSI_addListener};
|
|
34
|
+
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeTinyWavPackDecoderSpecJSI_removeListeners};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
std::shared_ptr<TurboModule> RNTinyWavPackDecoderSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
38
|
+
if (moduleName == "TinyWavPackDecoderModule") {
|
|
39
|
+
return std::make_shared<NativeTinyWavPackDecoderSpecJSI>(params);
|
|
40
|
+
}
|
|
41
|
+
return nullptr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeTinyWavPackDecoder'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeTinyWavPackDecoderSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeTinyWavPackDecoderSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> RNTinyWavPackDecoderSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNTinyWavPackDecoderSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeTinyWavPackDecoderCxxSpecJSI_decodeWavPack(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeTinyWavPackDecoderCxxSpecJSI *>(&turboModule)->decodeWavPack(
|
|
16
|
+
rt,
|
|
17
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
18
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
19
|
+
count <= 2 || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asNumber()),
|
|
20
|
+
count <= 3 || args[3].isUndefined() ? std::nullopt : std::make_optional(args[3].asNumber())
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
static jsi::Value __hostFunction_NativeTinyWavPackDecoderCxxSpecJSI_addListener(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
24
|
+
static_cast<NativeTinyWavPackDecoderCxxSpecJSI *>(&turboModule)->addListener(
|
|
25
|
+
rt,
|
|
26
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
27
|
+
);
|
|
28
|
+
return jsi::Value::undefined();
|
|
29
|
+
}
|
|
30
|
+
static jsi::Value __hostFunction_NativeTinyWavPackDecoderCxxSpecJSI_removeListeners(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
31
|
+
static_cast<NativeTinyWavPackDecoderCxxSpecJSI *>(&turboModule)->removeListeners(
|
|
32
|
+
rt,
|
|
33
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
34
|
+
);
|
|
35
|
+
return jsi::Value::undefined();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
NativeTinyWavPackDecoderCxxSpecJSI::NativeTinyWavPackDecoderCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
39
|
+
: TurboModule("TinyWavPackDecoderModule", jsInvoker) {
|
|
40
|
+
methodMap_["decodeWavPack"] = MethodMetadata {4, __hostFunction_NativeTinyWavPackDecoderCxxSpecJSI_decodeWavPack};
|
|
41
|
+
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeTinyWavPackDecoderCxxSpecJSI_addListener};
|
|
42
|
+
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeTinyWavPackDecoderCxxSpecJSI_removeListeners};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeTinyWavPackDecoderCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeTinyWavPackDecoderCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual jsi::Value decodeWavPack(jsi::Runtime &rt, jsi::String inputPath, jsi::String outputPath, std::optional<double> maxSamples, std::optional<double> bitsPerSample) = 0;
|
|
24
|
+
virtual void addListener(jsi::Runtime &rt, jsi::String eventType) = 0;
|
|
25
|
+
virtual void removeListeners(jsi::Runtime &rt, double count) = 0;
|
|
26
|
+
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
template <typename T>
|
|
30
|
+
class JSI_EXPORT NativeTinyWavPackDecoderCxxSpec : public TurboModule {
|
|
31
|
+
public:
|
|
32
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
33
|
+
return delegate_.create(rt, propName);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
37
|
+
return delegate_.getPropertyNames(runtime);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static constexpr std::string_view kModuleName = "TinyWavPackDecoderModule";
|
|
41
|
+
|
|
42
|
+
protected:
|
|
43
|
+
NativeTinyWavPackDecoderCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
44
|
+
: TurboModule(std::string{NativeTinyWavPackDecoderCxxSpec::kModuleName}, jsInvoker),
|
|
45
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
class Delegate : public NativeTinyWavPackDecoderCxxSpecJSI {
|
|
50
|
+
public:
|
|
51
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
52
|
+
NativeTinyWavPackDecoderCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
jsi::Value decodeWavPack(jsi::Runtime &rt, jsi::String inputPath, jsi::String outputPath, std::optional<double> maxSamples, std::optional<double> bitsPerSample) override {
|
|
57
|
+
static_assert(
|
|
58
|
+
bridging::getParameterCount(&T::decodeWavPack) == 5,
|
|
59
|
+
"Expected decodeWavPack(...) to have 5 parameters");
|
|
60
|
+
|
|
61
|
+
return bridging::callFromJs<jsi::Value>(
|
|
62
|
+
rt, &T::decodeWavPack, jsInvoker_, instance_, std::move(inputPath), std::move(outputPath), std::move(maxSamples), std::move(bitsPerSample));
|
|
63
|
+
}
|
|
64
|
+
void addListener(jsi::Runtime &rt, jsi::String eventType) override {
|
|
65
|
+
static_assert(
|
|
66
|
+
bridging::getParameterCount(&T::addListener) == 2,
|
|
67
|
+
"Expected addListener(...) to have 2 parameters");
|
|
68
|
+
|
|
69
|
+
return bridging::callFromJs<void>(
|
|
70
|
+
rt, &T::addListener, jsInvoker_, instance_, std::move(eventType));
|
|
71
|
+
}
|
|
72
|
+
void removeListeners(jsi::Runtime &rt, double count) override {
|
|
73
|
+
static_assert(
|
|
74
|
+
bridging::getParameterCount(&T::removeListeners) == 2,
|
|
75
|
+
"Expected removeListeners(...) to have 2 parameters");
|
|
76
|
+
|
|
77
|
+
return bridging::callFromJs<void>(
|
|
78
|
+
rt, &T::removeListeners, jsInvoker_, instance_, std::move(count));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private:
|
|
82
|
+
friend class NativeTinyWavPackDecoderCxxSpec;
|
|
83
|
+
T *instance_;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
Delegate delegate_;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# android/src/main/cpp/CMakeLists.txt
|
|
2
|
+
cmake_minimum_required(VERSION 3.4.1)
|
|
3
|
+
|
|
4
|
+
# Add logging library for android logcat
|
|
5
|
+
find_library(log-lib log)
|
|
6
|
+
|
|
7
|
+
# Set the path to the tiny wavpack library source files
|
|
8
|
+
set(WAVPACK_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tiny-wavpack/lib)
|
|
9
|
+
|
|
10
|
+
# Set the path to the common decoder interface implementation
|
|
11
|
+
set(COMMON_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tiny-wavpack/common)
|
|
12
|
+
|
|
13
|
+
# Add the tiny wavpack library source files
|
|
14
|
+
add_library(tiny_wavpack
|
|
15
|
+
STATIC
|
|
16
|
+
${WAVPACK_SRC_DIR}/bits.c
|
|
17
|
+
${WAVPACK_SRC_DIR}/float.c
|
|
18
|
+
${WAVPACK_SRC_DIR}/metadata.c
|
|
19
|
+
${WAVPACK_SRC_DIR}/unpack.c
|
|
20
|
+
${WAVPACK_SRC_DIR}/words.c
|
|
21
|
+
${WAVPACK_SRC_DIR}/wputils.c)
|
|
22
|
+
|
|
23
|
+
# Include directories for the tiny wavpack library
|
|
24
|
+
target_include_directories(tiny_wavpack PUBLIC ${WAVPACK_SRC_DIR})
|
|
25
|
+
|
|
26
|
+
# Add the common decoder implementation
|
|
27
|
+
add_library(common_decoder
|
|
28
|
+
STATIC
|
|
29
|
+
${COMMON_SRC_DIR}/TinyWavPackDecoderInterface.c)
|
|
30
|
+
|
|
31
|
+
# Includes both the common and WavPack headers
|
|
32
|
+
target_include_directories(common_decoder PUBLIC
|
|
33
|
+
${COMMON_SRC_DIR}
|
|
34
|
+
${WAVPACK_SRC_DIR})
|
|
35
|
+
|
|
36
|
+
# Link wavpack library to common decoder
|
|
37
|
+
target_link_libraries(common_decoder tiny_wavpack)
|
|
38
|
+
|
|
39
|
+
# Add the JNI implementation
|
|
40
|
+
add_library(tiny-wavpack-decoder
|
|
41
|
+
SHARED
|
|
42
|
+
TinyWavPackDecoderModule.cpp)
|
|
43
|
+
|
|
44
|
+
# Include directories for the JNI implementation
|
|
45
|
+
target_include_directories(tiny-wavpack-decoder PUBLIC
|
|
46
|
+
${COMMON_SRC_DIR}
|
|
47
|
+
${WAVPACK_SRC_DIR})
|
|
48
|
+
|
|
49
|
+
# Link the libraries
|
|
50
|
+
target_link_libraries(tiny-wavpack-decoder
|
|
51
|
+
common_decoder
|
|
52
|
+
tiny_wavpack
|
|
53
|
+
${log-lib}
|
|
54
|
+
android)
|