@audio/decode 3.11.3 → 3.12.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/package.json +13 -13
- package/readme.md +36 -36
- package/test.html +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/decode",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0",
|
|
4
4
|
"description": "Decode audio data in node or browser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"packages/*"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@audio/decode-aac": "^1.
|
|
32
|
-
"@audio/decode-aiff": "^1.
|
|
33
|
-
"@audio/decode-amr": "^1.
|
|
34
|
-
"@audio/decode-caf": "^1.
|
|
35
|
-
"@audio/decode-flac": "^1.
|
|
36
|
-
"@audio/decode-mp3": "^1.
|
|
37
|
-
"@audio/decode-opus": "^1.
|
|
38
|
-
"@audio/decode-qoa": "^1.
|
|
39
|
-
"@audio/decode-vorbis": "^1.
|
|
40
|
-
"@audio/decode-wav": "^1.
|
|
41
|
-
"@audio/decode-webm": "^1.
|
|
42
|
-
"@audio/decode-wma": "^1.
|
|
31
|
+
"@audio/decode-aac": "^1.4.0",
|
|
32
|
+
"@audio/decode-aiff": "^1.3.0",
|
|
33
|
+
"@audio/decode-amr": "^1.3.0",
|
|
34
|
+
"@audio/decode-caf": "^1.4.0",
|
|
35
|
+
"@audio/decode-flac": "^1.3.0",
|
|
36
|
+
"@audio/decode-mp3": "^1.3.0",
|
|
37
|
+
"@audio/decode-opus": "^1.3.0",
|
|
38
|
+
"@audio/decode-qoa": "^1.2.0",
|
|
39
|
+
"@audio/decode-vorbis": "^1.3.0",
|
|
40
|
+
"@audio/decode-wav": "^1.5.0",
|
|
41
|
+
"@audio/decode-webm": "^1.4.0",
|
|
42
|
+
"@audio/decode-wma": "^1.3.0",
|
|
43
43
|
"audio-type": "^2.4.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
package/readme.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @audio/decode [](https://github.com/audiojs/decode/actions/workflows/test.js.yml)
|
|
2
2
|
|
|
3
3
|
Decode any audio format to raw samples.<br>
|
|
4
|
-
JS / WASM
|
|
4
|
+
JS / WASM with no ffmpeg or native bindings; works in Node.js and browsers.<br>
|
|
5
5
|
Small API, minimal size, near-native performance, lazy-loading, chunked decoding.
|
|
6
6
|
|
|
7
|
-
[](https://npmjs.org/package/@audio/decode/)
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
10
|
import decode from '@audio/decode';
|
|
@@ -17,22 +17,22 @@ const { channelData, sampleRate } = await decode(anyAudioBuffer);
|
|
|
17
17
|
| Format | Package | Size | Engine |
|
|
18
18
|
|--------|---------|------|--------|
|
|
19
19
|
| MP3 | [@audio/decode-mp3](./packages/decode-mp3) | 92 KB | WASM |
|
|
20
|
-
| WAV | [@audio/decode-wav](./packages/decode-wav) |
|
|
21
|
-
| OGG Vorbis | [@audio/decode-vorbis](./packages/decode-vorbis) |
|
|
22
|
-
| FLAC | [@audio/decode-flac](./packages/decode-flac) |
|
|
23
|
-
| Opus | [@audio/decode-opus](./packages/decode-opus) |
|
|
20
|
+
| WAV | [@audio/decode-wav](./packages/decode-wav) | 11 KB | JS |
|
|
21
|
+
| OGG Vorbis | [@audio/decode-vorbis](./packages/decode-vorbis) | 166 KB | WASM |
|
|
22
|
+
| FLAC | [@audio/decode-flac](./packages/decode-flac) | 135 KB | WASM |
|
|
23
|
+
| Opus | [@audio/decode-opus](./packages/decode-opus) | 166 KB | WASM |
|
|
24
24
|
| M4A / AAC / ALAC | [@audio/decode-aac](./packages/decode-aac) | 368 KB | WASM + JS |
|
|
25
25
|
| QOA | [@audio/decode-qoa](./packages/decode-qoa) | 8 KB | JS |
|
|
26
26
|
| AIFF | [@audio/decode-aiff](./packages/decode-aiff) | 20 KB | JS |
|
|
27
|
-
| CAF | [@audio/decode-caf](./packages/decode-caf) |
|
|
28
|
-
| WebM | [@audio/decode-webm](./packages/decode-webm) |
|
|
27
|
+
| CAF | [@audio/decode-caf](./packages/decode-caf) | 9 KB | JS |
|
|
28
|
+
| WebM | [@audio/decode-webm](./packages/decode-webm) | 250 KB | WASM |
|
|
29
29
|
| AMR | [@audio/decode-amr](./packages/decode-amr) | 241 KB | WASM |
|
|
30
30
|
| WMA | [@audio/decode-wma](./packages/decode-wma) | 91 KB | WASM |
|
|
31
31
|
|
|
32
32
|
### Whole-file
|
|
33
33
|
|
|
34
34
|
Auto-detects format. Input can be _ArrayBuffer_, _Uint8Array_, _Buffer_, or anything
|
|
35
|
-
that materializes to bytes
|
|
35
|
+
that materializes to bytes, including a _Blob_/_File_ or fetch _Response_.
|
|
36
36
|
|
|
37
37
|
```js
|
|
38
38
|
import decode from '@audio/decode'
|
|
@@ -42,6 +42,27 @@ let fromFile = await decode(fileInput.files[0]) // File
|
|
|
42
42
|
let fromUrl = await decode(await fetch(url)) // Response
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
### Synchronous codecs
|
|
46
|
+
|
|
47
|
+
The umbrella remains async for detection, lazy imports, and `Blob`/`Response` inputs.
|
|
48
|
+
Import a codec package directly for synchronous calls.
|
|
49
|
+
|
|
50
|
+
`wav`, `qoa`, `aiff`, and `caf` are synchronous:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import decode from '@audio/decode-wav'
|
|
54
|
+
let pcm = decode(wavBytes)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
WASM codecs initialize asynchronously, then decode synchronously:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import { decoder } from '@audio/decode-flac'
|
|
61
|
+
let dec = await decoder()
|
|
62
|
+
let pcm = dec.decode(bytes)
|
|
63
|
+
let tail = dec.flush()
|
|
64
|
+
dec.free()
|
|
65
|
+
```
|
|
45
66
|
|
|
46
67
|
### Chunked
|
|
47
68
|
|
|
@@ -68,37 +89,16 @@ Formats: `mp3`, `flac`, `opus`, `oga`, `m4a`, `wav`, `qoa`, `aac`, `aiff`, `caf`
|
|
|
68
89
|
|
|
69
90
|
### Browser
|
|
70
91
|
|
|
71
|
-
|
|
72
|
-
For selective loading in the browser (avoids bundling all codecs):
|
|
92
|
+
Works from a CDN without a bundler. Codecs load on demand via dynamic import, only for formats you decode:
|
|
73
93
|
|
|
74
94
|
```html
|
|
75
|
-
<script type="importmap">
|
|
76
|
-
{
|
|
77
|
-
"imports": {
|
|
78
|
-
"@audio/decode": "https://esm.sh/audio-decode",
|
|
79
|
-
"audio-type": "https://esm.sh/audio-type",
|
|
80
|
-
"@audio/decode-mp3": "https://esm.sh/@audio/decode-mp3",
|
|
81
|
-
"@audio/decode-wav": "https://esm.sh/@audio/decode-wav",
|
|
82
|
-
"@audio/decode-flac": "https://esm.sh/@audio/decode-flac",
|
|
83
|
-
"@audio/decode-opus": "https://esm.sh/@audio/decode-opus",
|
|
84
|
-
"@audio/decode-vorbis": "https://esm.sh/@audio/decode-vorbis",
|
|
85
|
-
"@audio/decode-aac": "https://esm.sh/@audio/decode-aac",
|
|
86
|
-
"@audio/decode-qoa": "https://esm.sh/@audio/decode-qoa",
|
|
87
|
-
"@audio/decode-aiff": "https://esm.sh/@audio/decode-aiff",
|
|
88
|
-
"@audio/decode-caf": "https://esm.sh/@audio/decode-caf",
|
|
89
|
-
"@audio/decode-webm": "https://esm.sh/@audio/decode-webm",
|
|
90
|
-
"@audio/decode-amr": "https://esm.sh/@audio/decode-amr",
|
|
91
|
-
"@audio/decode-wma": "https://esm.sh/@audio/decode-wma"
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
</script>
|
|
95
95
|
<script type="module">
|
|
96
|
-
import decode from '
|
|
96
|
+
import decode from 'https://esm.sh/@audio/decode'
|
|
97
97
|
let { channelData, sampleRate } = await decode(buf)
|
|
98
98
|
</script>
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
For self-hosting, use an import map to point `@audio/decode` and each needed `@audio/decode-*` package to local files. Codec-internal files load by relative path.
|
|
102
102
|
|
|
103
103
|
### Metadata
|
|
104
104
|
|
|
@@ -123,7 +123,7 @@ let info = parseMeta(wavBytes)
|
|
|
123
123
|
|
|
124
124
|
### WebWorker
|
|
125
125
|
|
|
126
|
-
Each `@audio/decode-*` package is a self-contained ESM module
|
|
126
|
+
Each `@audio/decode-*` package is a self-contained ESM module that can run in a worker:
|
|
127
127
|
|
|
128
128
|
```js
|
|
129
129
|
// decode-worker.js
|
|
@@ -151,6 +151,6 @@ worker.onmessage = ({ data }) => { /* { channelData, sampleRate } */ }
|
|
|
151
151
|
* [ffmpeg.wasm](https://github.com/ffmpegwasm/ffmpeg.wasm) – full encoding/decoding library.
|
|
152
152
|
-->
|
|
153
153
|
|
|
154
|
-
<p align="center">Licensing: the umbrella and most codec
|
|
154
|
+
<p align="center">Licensing: the umbrella and most codec packages are MIT. Three codecs use another license: <a href="./packages/decode-aac">@audio/decode-aac</a> GPL-2.0, <a href="./packages/decode-wma">@audio/decode-wma</a> GPL-2.0-or-later, and <a href="./packages/decode-amr">@audio/decode-amr</a> Apache-2.0. Install only the codecs whose licenses fit your project. The umbrella loads them on demand.</p>
|
|
155
155
|
|
|
156
|
-
<p align="center"><a href="
|
|
156
|
+
<p align="center"><a href="https://github.com/krishnized/license/">ॐ</a> · <a href="./LICENSE">MIT</a>
|
package/test.html
CHANGED
|
@@ -17,11 +17,17 @@
|
|
|
17
17
|
"audio-type": "./node_modules/audio-type/audio-type.js",
|
|
18
18
|
"tst": "./node_modules/tst/tst.js",
|
|
19
19
|
"@audio/decode-mp3": "./packages/decode-mp3/decode-mp3.js",
|
|
20
|
+
"@audio/decode-mp3/meta": "./packages/decode-mp3/meta.js",
|
|
20
21
|
"@audio/decode-wav": "./packages/decode-wav/decode-wav.js",
|
|
22
|
+
"@audio/decode-wav/meta": "./packages/decode-wav/meta.js",
|
|
21
23
|
"@audio/decode-flac": "./packages/decode-flac/decode-flac.js",
|
|
24
|
+
"@audio/decode-flac/meta": "./packages/decode-flac/meta.js",
|
|
22
25
|
"@audio/decode-opus": "./packages/decode-opus/decode-opus.js",
|
|
26
|
+
"@audio/decode-opus/meta": "./packages/decode-opus/meta.js",
|
|
23
27
|
"@audio/decode-vorbis": "./packages/decode-vorbis/decode-vorbis.js",
|
|
28
|
+
"@audio/decode-vorbis/meta": "./packages/decode-vorbis/meta.js",
|
|
24
29
|
"@audio/decode-aac": "./packages/decode-aac/decode-aac.js",
|
|
30
|
+
"@audio/decode-aac/meta": "./packages/decode-aac/meta.js",
|
|
25
31
|
"@audio/decode-qoa": "./packages/decode-qoa/decode-qoa.js",
|
|
26
32
|
"@audio/decode-aiff": "./packages/decode-aiff/decode-aiff.js",
|
|
27
33
|
"@audio/decode-caf": "./packages/decode-caf/decode-caf.js",
|