react-native-tiny-wavpack-decoder 0.1.0 → 1.0.2

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/README.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # react-native-tiny-wavpack-decoder
2
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.
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 also supports progress updates during decoding.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/react-native-tiny-wavpack-decoder)](https://badge.fury.io/js/react-native-tiny-wavpack-decoder) [![License](https://img.shields.io/github/license/JairajJangle/react-native-tiny-wavpack-decoder)](https://github.com/JairajJangle/react-native-tiny-wavpack-decoder/blob/main/LICENSE) [![Workflow Status](https://github.com/JairajJangle/react-native-tiny-wavpack-decoder/actions/workflows/ci.yml/badge.svg)](https://github.com/JairajJangle/react-native-tiny-wavpack-decoder/actions/workflows/ci.yml) ![Android](https://img.shields.io/badge/-Android-555555?logo=android&logoColor=3DDC84) ![iOS](https://img.shields.io/badge/-iOS-555555?logo=apple&logoColor=white) [![GitHub issues](https://img.shields.io/github/issues/JairajJangle/react-native-tiny-wavpack-decoder)](https://github.com/JairajJangle/react-native-tiny-wavpack-decoder/issues?q=is%3Aopen+is%3Aissue) ![TS](https://img.shields.io/badge/TypeScript-strict_💪-blue) [![Known Vulnerabilities](https://snyk.io/test/github/jairajjangle/react-native-tiny-wavpack-decoder/badge.svg)](https://snyk.io/test/github/jairajjangle/react-native-tiny-wavpack-decoder) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-native-tiny-wavpack-decoder)
6
+
7
+ <div align="center">
8
+ <img src="https://media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExbHI4d29ncW1kcGRjeXgwZnVnMzdnNHJnaXFmbzYxcHFud29kOGNkYiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/aT8unro6bwv9GWRLkt/giphy.gif" alt="Tiny WavPack Decoding demo" style="border: 1px solid gray;" />
9
+ </div>
4
10
 
5
11
  ## Features
12
+
6
13
  - Decode WavPack (.wv) files to WAV format.
7
14
  - Cross-platform support for iOS (13.0+) and Android (API 21+).
8
15
  - Progress updates via event emitter for real-time feedback.
@@ -10,7 +17,7 @@ A lightweight React Native Turbo Module for decoding WavPack audio files to WAV
10
17
  - Thread-safe decoding on iOS with concurrent queue support.
11
18
 
12
19
  ## Requirements
13
- - React Native 0.75 or higher with New Architecture enabled.
20
+ - React Native 0.77 or higher with New Architecture enabled.
14
21
  - iOS 13.0 or later.
15
22
  - Android API 21 or later.
16
23
  - Node.js 16+ for development.
@@ -145,4 +152,8 @@ MIT License. See [LICENSE](LICENSE) for details.
145
152
 
146
153
  ## Acknowledgments
147
154
  - 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.
155
+ - Uses React Native’s New Architecture for modern performance.
156
+
157
+ ---
158
+
159
+ ##### Library for encoder coming soon...
@@ -1,140 +1,140 @@
1
- ////////////////////////////////////////////////////////////////////////////
2
- // **** WAVPACK **** //
3
- // Hybrid Lossless Wavefile Compressor //
4
- // Copyright (c) 1998 - 2006 Conifer Software. //
5
- // All Rights Reserved. //
6
- // Distributed under the BSD Software License (see license.txt) //
7
- ////////////////////////////////////////////////////////////////////////////
8
-
9
- // bits.c
10
-
11
- // This module provides utilities to support the BitStream structure which is
12
- // used to read and write all WavPack audio data streams. It also contains a
13
- // wrapper for the stream I/O functions and a set of functions dealing with
14
- // endian-ness, both for enhancing portability. Finally, a debug wrapper for
15
- // the malloc() system is provided.
16
-
17
- #include "wavpack.h"
18
-
19
- #include <string.h>
20
- #include <ctype.h>
21
-
22
- ////////////////////////// Bitstream functions ////////////////////////////////
23
-
24
- // Open the specified BitStream and associate with the specified buffer.
25
-
26
- static void bs_read (Bitstream *bs);
27
-
28
- void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, uint32_t file_bytes)
29
- {
30
- CLEAR (*bs);
31
- bs->buf = buffer_start;
32
- bs->end = buffer_end;
33
-
34
- if (file) {
35
- bs->ptr = bs->end - 1;
36
- bs->file_bytes = file_bytes;
37
- bs->file = file;
38
- }
39
- else
40
- bs->ptr = bs->buf - 1;
41
-
42
- bs->wrap = bs_read;
43
- }
44
-
45
- // This function is only called from the getbit() and getbits() macros when
46
- // the BitStream has been exhausted and more data is required. Sinve these
47
- // bistreams no longer access files, this function simple sets an error and
48
- // resets the buffer.
49
-
50
- static void bs_read (Bitstream *bs)
51
- {
52
- if (bs->file && bs->file_bytes) {
53
- uint32_t bytes_read, bytes_to_read = bs->end - bs->buf;
54
-
55
- if (bytes_to_read > bs->file_bytes)
56
- bytes_to_read = bs->file_bytes;
57
-
58
- bytes_read = bs->file (bs->buf, bytes_to_read);
59
-
60
- if (bytes_read) {
61
- bs->end = bs->buf + bytes_read;
62
- bs->file_bytes -= bytes_read;
63
- }
64
- else {
65
- memset (bs->buf, -1, bs->end - bs->buf);
66
- bs->error = 1;
67
- }
68
- }
69
- else
70
- bs->error = 1;
71
-
72
- if (bs->error)
73
- memset (bs->buf, -1, bs->end - bs->buf);
74
-
75
- bs->ptr = bs->buf;
76
- }
77
-
78
- /////////////////////// Endian Correction Routines ////////////////////////////
79
-
80
- void little_endian_to_native (void *data, char *format)
81
- {
82
- uchar *cp = (uchar *) data;
83
- int32_t temp;
84
-
85
- while (*format) {
86
- switch (*format) {
87
- case 'L':
88
- temp = cp [0] + ((int32_t) cp [1] << 8) + ((int32_t) cp [2] << 16) + ((int32_t) cp [3] << 24);
89
- * (int32_t *) cp = temp;
90
- cp += 4;
91
- break;
92
-
93
- case 'S':
94
- temp = cp [0] + (cp [1] << 8);
95
- * (short *) cp = (short) temp;
96
- cp += 2;
97
- break;
98
-
99
- default:
100
- if (isdigit (*format))
101
- cp += *format - '0';
102
-
103
- break;
104
- }
105
-
106
- format++;
107
- }
108
- }
109
-
110
- void native_to_little_endian (void *data, char *format)
111
- {
112
- uchar *cp = (uchar *) data;
113
- int32_t temp;
114
-
115
- while (*format) {
116
- switch (*format) {
117
- case 'L':
118
- temp = * (int32_t *) cp;
119
- *cp++ = (uchar) temp;
120
- *cp++ = (uchar) (temp >> 8);
121
- *cp++ = (uchar) (temp >> 16);
122
- *cp++ = (uchar) (temp >> 24);
123
- break;
124
-
125
- case 'S':
126
- temp = * (short *) cp;
127
- *cp++ = (uchar) temp;
128
- *cp++ = (uchar) (temp >> 8);
129
- break;
130
-
131
- default:
132
- if (isdigit (*format))
133
- cp += *format - '0';
134
-
135
- break;
136
- }
137
-
138
- format++;
139
- }
140
- }
1
+ ////////////////////////////////////////////////////////////////////////////
2
+ // **** WAVPACK **** //
3
+ // Hybrid Lossless Wavefile Compressor //
4
+ // Copyright (c) 1998 - 2006 Conifer Software. //
5
+ // All Rights Reserved. //
6
+ // Distributed under the BSD Software License (see license.txt) //
7
+ ////////////////////////////////////////////////////////////////////////////
8
+
9
+ // bits.c
10
+
11
+ // This module provides utilities to support the BitStream structure which is
12
+ // used to read and write all WavPack audio data streams. It also contains a
13
+ // wrapper for the stream I/O functions and a set of functions dealing with
14
+ // endian-ness, both for enhancing portability. Finally, a debug wrapper for
15
+ // the malloc() system is provided.
16
+
17
+ #include "wavpack.h"
18
+
19
+ #include <string.h>
20
+ #include <ctype.h>
21
+
22
+ ////////////////////////// Bitstream functions ////////////////////////////////
23
+
24
+ // Open the specified BitStream and associate with the specified buffer.
25
+
26
+ static void bs_read (Bitstream *bs);
27
+
28
+ void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, uint32_t file_bytes)
29
+ {
30
+ CLEAR (*bs);
31
+ bs->buf = buffer_start;
32
+ bs->end = buffer_end;
33
+
34
+ if (file) {
35
+ bs->ptr = bs->end - 1;
36
+ bs->file_bytes = file_bytes;
37
+ bs->file = file;
38
+ }
39
+ else
40
+ bs->ptr = bs->buf - 1;
41
+
42
+ bs->wrap = bs_read;
43
+ }
44
+
45
+ // This function is only called from the getbit() and getbits() macros when
46
+ // the BitStream has been exhausted and more data is required. Sinve these
47
+ // bistreams no longer access files, this function simple sets an error and
48
+ // resets the buffer.
49
+
50
+ static void bs_read (Bitstream *bs)
51
+ {
52
+ if (bs->file && bs->file_bytes) {
53
+ uint32_t bytes_read, bytes_to_read = bs->end - bs->buf;
54
+
55
+ if (bytes_to_read > bs->file_bytes)
56
+ bytes_to_read = bs->file_bytes;
57
+
58
+ bytes_read = bs->file (bs->buf, bytes_to_read);
59
+
60
+ if (bytes_read) {
61
+ bs->end = bs->buf + bytes_read;
62
+ bs->file_bytes -= bytes_read;
63
+ }
64
+ else {
65
+ memset (bs->buf, -1, bs->end - bs->buf);
66
+ bs->error = 1;
67
+ }
68
+ }
69
+ else
70
+ bs->error = 1;
71
+
72
+ if (bs->error)
73
+ memset (bs->buf, -1, bs->end - bs->buf);
74
+
75
+ bs->ptr = bs->buf;
76
+ }
77
+
78
+ /////////////////////// Endian Correction Routines ////////////////////////////
79
+
80
+ void little_endian_to_native (void *data, char *format)
81
+ {
82
+ uchar *cp = (uchar *) data;
83
+ int32_t temp;
84
+
85
+ while (*format) {
86
+ switch (*format) {
87
+ case 'L':
88
+ temp = cp [0] + ((int32_t) cp [1] << 8) + ((int32_t) cp [2] << 16) + ((int32_t) cp [3] << 24);
89
+ * (int32_t *) cp = temp;
90
+ cp += 4;
91
+ break;
92
+
93
+ case 'S':
94
+ temp = cp [0] + (cp [1] << 8);
95
+ * (short *) cp = (short) temp;
96
+ cp += 2;
97
+ break;
98
+
99
+ default:
100
+ if (isdigit (*format))
101
+ cp += *format - '0';
102
+
103
+ break;
104
+ }
105
+
106
+ format++;
107
+ }
108
+ }
109
+
110
+ void native_to_little_endian (void *data, char *format)
111
+ {
112
+ uchar *cp = (uchar *) data;
113
+ int32_t temp;
114
+
115
+ while (*format) {
116
+ switch (*format) {
117
+ case 'L':
118
+ temp = * (int32_t *) cp;
119
+ *cp++ = (uchar) temp;
120
+ *cp++ = (uchar) (temp >> 8);
121
+ *cp++ = (uchar) (temp >> 16);
122
+ *cp++ = (uchar) (temp >> 24);
123
+ break;
124
+
125
+ case 'S':
126
+ temp = * (short *) cp;
127
+ *cp++ = (uchar) temp;
128
+ *cp++ = (uchar) (temp >> 8);
129
+ break;
130
+
131
+ default:
132
+ if (isdigit (*format))
133
+ cp += *format - '0';
134
+
135
+ break;
136
+ }
137
+
138
+ format++;
139
+ }
140
+ }
@@ -1,50 +1,50 @@
1
- ////////////////////////////////////////////////////////////////////////////
2
- // **** WAVPACK **** //
3
- // Hybrid Lossless Wavefile Compressor //
4
- // Copyright (c) 1998 - 2006 Conifer Software. //
5
- // All Rights Reserved. //
6
- // Distributed under the BSD Software License (see license.txt) //
7
- ////////////////////////////////////////////////////////////////////////////
8
-
9
- // float.c
10
-
11
- #include "wavpack.h"
12
-
13
- int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
14
- {
15
- int bytecnt = wpmd->byte_length;
16
- char *byteptr = wpmd->data;
17
-
18
- if (bytecnt != 4)
19
- return FALSE;
20
-
21
- wps->float_flags = *byteptr++;
22
- wps->float_shift = *byteptr++;
23
- wps->float_max_exp = *byteptr++;
24
- wps->float_norm_exp = *byteptr;
25
- return TRUE;
26
- }
27
-
28
- void float_values (WavpackStream *wps, int32_t *values, int32_t num_values)
29
- {
30
- int shift = wps->float_max_exp - wps->float_norm_exp + wps->float_shift;
31
-
32
- if (shift > 32)
33
- shift = 32;
34
- else if (shift < -32)
35
- shift = -32;
36
-
37
- while (num_values--) {
38
- if (shift > 0)
39
- *values <<= shift;
40
- else if (shift < 0)
41
- *values >>= -shift;
42
-
43
- if (*values > 8388607L)
44
- *values = 8388607L;
45
- else if (*values < -8388608L)
46
- *values = -8388608L;
47
-
48
- values++;
49
- }
50
- }
1
+ ////////////////////////////////////////////////////////////////////////////
2
+ // **** WAVPACK **** //
3
+ // Hybrid Lossless Wavefile Compressor //
4
+ // Copyright (c) 1998 - 2006 Conifer Software. //
5
+ // All Rights Reserved. //
6
+ // Distributed under the BSD Software License (see license.txt) //
7
+ ////////////////////////////////////////////////////////////////////////////
8
+
9
+ // float.c
10
+
11
+ #include "wavpack.h"
12
+
13
+ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
14
+ {
15
+ int bytecnt = wpmd->byte_length;
16
+ char *byteptr = wpmd->data;
17
+
18
+ if (bytecnt != 4)
19
+ return FALSE;
20
+
21
+ wps->float_flags = *byteptr++;
22
+ wps->float_shift = *byteptr++;
23
+ wps->float_max_exp = *byteptr++;
24
+ wps->float_norm_exp = *byteptr;
25
+ return TRUE;
26
+ }
27
+
28
+ void float_values (WavpackStream *wps, int32_t *values, int32_t num_values)
29
+ {
30
+ int shift = wps->float_max_exp - wps->float_norm_exp + wps->float_shift;
31
+
32
+ if (shift > 32)
33
+ shift = 32;
34
+ else if (shift < -32)
35
+ shift = -32;
36
+
37
+ while (num_values--) {
38
+ if (shift > 0)
39
+ *values <<= shift;
40
+ else if (shift < 0)
41
+ *values >>= -shift;
42
+
43
+ if (*values > 8388607L)
44
+ *values = 8388607L;
45
+ else if (*values < -8388608L)
46
+ *values = -8388608L;
47
+
48
+ values++;
49
+ }
50
+ }
@@ -1,25 +1,25 @@
1
- Copyright (c) 1998 - 2006 Conifer Software
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice,
8
- this list of conditions and the following disclaimer.
9
- * Redistributions in binary form must reproduce the above copyright notice,
10
- this list of conditions and the following disclaimer in the
11
- documentation and/or other materials provided with the distribution.
12
- * Neither the name of Conifer Software nor the names of its contributors
13
- may be used to endorse or promote products derived from this software
14
- without specific prior written permission.
15
-
16
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
- ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
20
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ Copyright (c) 1998 - 2006 Conifer Software
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ * Neither the name of Conifer Software nor the names of its contributors
13
+ may be used to endorse or promote products derived from this software
14
+ without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
20
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.