carta1 1.0.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 +15 -0
- package/README.md +129 -0
- package/bin/cli.js +679 -0
- package/codec/analysis/psychoacoustics.js +589 -0
- package/codec/analysis/transient.js +226 -0
- package/codec/browser/interface.js +188 -0
- package/codec/browser/worker.js +140 -0
- package/codec/coding/bitallocation.js +407 -0
- package/codec/coding/quantization.js +150 -0
- package/codec/core/bitstream.js +82 -0
- package/codec/core/buffers.js +99 -0
- package/codec/core/constants.js +321 -0
- package/codec/core/options.js +151 -0
- package/codec/index.js +27 -0
- package/codec/io/processor.js +566 -0
- package/codec/io/readers.js +56 -0
- package/codec/io/serialization.js +254 -0
- package/codec/pipeline/decoder.js +278 -0
- package/codec/pipeline/encoder.js +369 -0
- package/codec/transforms/fft.js +69 -0
- package/codec/transforms/mdct.js +225 -0
- package/codec/transforms/qmf.js +127 -0
- package/codec/utils.js +151 -0
- package/dist/carta1-worker-interface.min.js +2 -0
- package/dist/carta1-worker-interface.min.js.map +1 -0
- package/dist/carta1-worker.min.js +2 -0
- package/dist/carta1-worker.min.js.map +1 -0
- package/dist/carta1.min.js +2 -0
- package/dist/carta1.min.js.map +1 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, aynik
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Carta1
|
|
2
|
+
|
|
3
|
+
An ATRAC1 audio codec implementation in JS.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Pure JavaScript implementation of ATRAC1 codec
|
|
8
|
+
- Encoding WAV to AEA (ATRAC1) format
|
|
9
|
+
- Decoding AEA to WAV format
|
|
10
|
+
- Command-line interface
|
|
11
|
+
- Browser-compatible with Web Workers
|
|
12
|
+
- Streaming support for large files
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install carta1
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## CLI Usage
|
|
21
|
+
|
|
22
|
+
### Encoding
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
carta1 --encode input.wav output.aea
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Decoding
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
carta1 --decode input.aea output.wav
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Options
|
|
35
|
+
|
|
36
|
+
- `-e, --encode` - Encode WAV to AEA
|
|
37
|
+
- `-d, --decode` - Decode AEA to WAV
|
|
38
|
+
- `-j, --json` - Dump AEA file structure to JSON
|
|
39
|
+
- `-q, --quiet` - Suppress all output except errors
|
|
40
|
+
- `-f, --force` - Overwrite output file if it exists
|
|
41
|
+
- `-t, --title <title>` - Custom title for AEA file metadata (encoding only)
|
|
42
|
+
|
|
43
|
+
## Browser Usage
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<script src="https://unpkg.com/carta1/dist/carta1-worker.min.js"></script>
|
|
47
|
+
<script src="https://unpkg.com/carta1/dist/carta1-worker-interface.min.js"></script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
// Create codec instance
|
|
52
|
+
const codec = new Carta1Worker('carta1-worker.min.js')
|
|
53
|
+
|
|
54
|
+
// Encode PCM to ATRAC1
|
|
55
|
+
const result = await codec.encode(pcmData, options)
|
|
56
|
+
|
|
57
|
+
// Decode ATRAC1 to PCM
|
|
58
|
+
const wavData = await codec.decode(aeaData)
|
|
59
|
+
|
|
60
|
+
// Clean up
|
|
61
|
+
codec.terminate()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## API Reference
|
|
65
|
+
|
|
66
|
+
### Node.js
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
import { encode, decode, AudioProcessor } from 'carta1'
|
|
70
|
+
|
|
71
|
+
// Encode PCM frames
|
|
72
|
+
const encoder = encode(options)
|
|
73
|
+
const encodedFrame = encoder(pcmFrame)
|
|
74
|
+
|
|
75
|
+
// Decode ATRAC1 frames
|
|
76
|
+
const decoder = decode()
|
|
77
|
+
const pcmFrame = decoder(encodedFrame)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Browser Worker API
|
|
81
|
+
|
|
82
|
+
#### `new Carta1Worker(workerPath)`
|
|
83
|
+
|
|
84
|
+
Create a new codec worker instance.
|
|
85
|
+
|
|
86
|
+
#### `encode(pcmData, options)`
|
|
87
|
+
|
|
88
|
+
Encode PCM audio data to ATRAC1 format.
|
|
89
|
+
|
|
90
|
+
#### `decode(aeaData)`
|
|
91
|
+
|
|
92
|
+
Decode ATRAC1 data to PCM format.
|
|
93
|
+
|
|
94
|
+
#### `parseAeaBlob(blob)`
|
|
95
|
+
|
|
96
|
+
Parse AEA file blob to extract metadata.
|
|
97
|
+
|
|
98
|
+
#### `terminate()`
|
|
99
|
+
|
|
100
|
+
Clean up worker resources.
|
|
101
|
+
|
|
102
|
+
## Development
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Install dependencies
|
|
106
|
+
npm install
|
|
107
|
+
|
|
108
|
+
# Run tests
|
|
109
|
+
npm test
|
|
110
|
+
|
|
111
|
+
# Build minified versions
|
|
112
|
+
npm run build
|
|
113
|
+
|
|
114
|
+
# Lint code
|
|
115
|
+
npm run lint
|
|
116
|
+
|
|
117
|
+
# Format code
|
|
118
|
+
npm run format
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Acknowledgements
|
|
122
|
+
|
|
123
|
+
This project would not have been possible without:
|
|
124
|
+
|
|
125
|
+
- [**AtracDEnc**](https://github.com/dcherednik/atracdenc) by [Daniel Cherednik](https://github.com/dcherednik) - The reference ATRAC implementation that provided invaluable insights into the codec's inner workings and served as the primary source for understanding the ATRAC1 format specification.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
ISC
|