@audio/decode-aac 1.3.4 → 1.4.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @audio/decode-aac
2
2
 
3
- Decode AAC/M4A and ALAC (Apple Lossless) audio to PCM float samples. AAC via FAAD2 (WASM); ALAC via a pure-JS port of Apple's reference decoder — auto-detected from the M4A sample entry. Works in Node.js and browsers, no native dependencies.
3
+ Decode AAC/M4A and ALAC audio to PCM float samples. FAAD2 WASM handles AAC; a pure-JS port of Apple's reference decoder handles ALAC. The M4A sample entry selects the codec.
4
4
 
5
5
  ## Install
6
6
 
@@ -13,7 +13,7 @@ npm i @audio/decode-aac
13
13
  ```js
14
14
  import decode from '@audio/decode-aac'
15
15
 
16
- // M4A or raw ADTS — auto-detected
16
+ // M4A or raw ADTS; auto-detected
17
17
  let { channelData, sampleRate } = await decode(uint8array)
18
18
  // channelData: Float32Array[] (one per channel)
19
19
  // sampleRate: number
@@ -29,6 +29,8 @@ let { channelData, sampleRate } = dec.decode(chunk)
29
29
  dec.free()
30
30
  ```
31
31
 
32
+ `decoder()` is asynchronous. Its `decode()` and `flush()` methods are synchronous.
33
+
32
34
  ## API
33
35
 
34
36
  ### `decode(src: Uint8Array | ArrayBuffer): Promise<AudioData>`
@@ -39,9 +41,9 @@ Whole-file decode. Auto-detects M4A (MP4 container) vs raw ADTS.
39
41
 
40
42
  Creates a decoder instance for manual control.
41
43
 
42
- - **`dec.decode(data)`** — decode chunk, returns `{ channelData, sampleRate }`
43
- - **`dec.flush()`** — flush remaining (returns empty for AAC)
44
- - **`dec.free()`** — release WASM memory
44
+ - `dec.decode(data)`: decode a `Uint8Array` or `ArrayBuffer` chunk.
45
+ - `dec.flush()`: discard buffered partial data and return an empty result.
46
+ - `dec.free()`: release WASM memory.
45
47
 
46
48
  ### `AudioData`
47
49
 
@@ -51,8 +53,8 @@ Creates a decoder instance for manual control.
51
53
 
52
54
  ## Formats
53
55
 
54
- - M4A / MP4 with AAC audio (LC, HE-AAC v1/v2 — SBR, PS)
55
- - M4A / MP4 with ALAC (Apple Lossless), 16/20/24/32-bit — pure JS, bit-exact
56
+ - M4A / MP4 with AAC audio (LC and HE-AAC v1/v2 with SBR or PS)
57
+ - M4A / MP4 with bit-exact pure-JS ALAC decoding at 16, 20, 24, or 32 bits
56
58
  - Raw ADTS streams (.aac)
57
59
 
58
60
  ## Metadata
@@ -66,4 +68,4 @@ let { meta, sampleRate } = parseMeta(m4aBytes)
66
68
 
67
69
  ## License
68
70
 
69
- AAC decoding: GPL-2.0 (FAAD2). ALAC decoding: Apache-2.0 (port of Apple's ALAC reference). — [krishnized](https://github.com/krishnized/license)
71
+ [ॐ](https://github.com/krishnized/license/) · AAC decoding [GPL-2.0](./LICENSE) (FAAD2), ALAC decoding Apache-2.0 (port of Apple's ALAC reference)
package/decode-aac.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- interface AudioData {
1
+ export interface AudioData {
2
2
  channelData: Float32Array[];
3
3
  sampleRate: number;
4
4
  }
5
5
 
6
6
  interface AACDecoder {
7
- decode(data: Uint8Array): AudioData;
7
+ decode(data: Uint8Array | ArrayBuffer): AudioData;
8
8
  flush(): AudioData;
9
9
  free(): void;
10
10
  }
package/decode-aac.js CHANGED
@@ -74,7 +74,7 @@ class AACDecoder {
74
74
 
75
75
  decode(data) {
76
76
  if (this.done) throw Error('Decoder already freed')
77
- if (!data?.length) return EMPTY
77
+ if (!data || !data.byteLength) return EMPTY
78
78
 
79
79
  let buf = data instanceof Uint8Array ? data : new Uint8Array(data)
80
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/decode-aac",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "description": "Decode AAC/M4A (FAAD2 WASM) and ALAC/Apple Lossless (pure JS) to PCM samples",
5
5
  "type": "module",
6
6
  "main": "decode-aac.js",
package/src/aac.wasm.cjs CHANGED
Binary file