ws-audio2: TTA: codecs/audio/Tta (written from the TTA1 format description; no libtta / ffmpeg code) + audio/tta
TTA1 format 1, 8/16/24 bits, any channel count, header / seek table / frame CRC-32s, seeking, ID3v2 skipped, APEv2 tags; password-protected files -> UNSUPPORTED. 20 fixtures (ttaenc 3.4.1, the FATE inside.tta sample) bit-exact against ttaenc -d. Branch-free filter steps (LuaJIT: no register-coalescing aborts, 7 -> 40 MB/s). WavPack: the unary / gamma counts a byte at a time (LuaJIT traces). APE: the predictor rotations as single assignments. docs/guide/audio.md: the lossless section (+ tools/fixtures/docs_lossless.py inputs) and the Formats table.
This commit is contained in:
1 parent
ae8ff9d6bf
commit
085e385674
12 files changed
+857
-20
No files matched your search
+35
-1
@@ -189,7 +189,7 @@ Tags are written from `audio.tags`, or from the Decoder's `tags`, wherever the f
|
||||
|
||||
| Read and write | Read only |
|
||||
|---|---|
|
||||
| wav (+ RF64), flac (+ Ogg FLAC), mp3 / mp2, vorbis (.ogg), opus, aiff / aifc, au, voc, caf, m4a (ALAC) | aac (ADTS), m4a / caf AAC |
|
||||
| wav (+ RF64), flac (+ Ogg FLAC), mp3 / mp2, vorbis (.ogg), opus, aiff / aifc, au, voc, caf, m4a (ALAC) | aac (ADTS), m4a / caf AAC, wavpack (.wv + .wvc), ape, tta |
|
||||
|
||||
Each format's capabilities are listed in [FORMATS.md](../FORMATS.md). The audio tracks of video files open as
|
||||
Decoders too: see `v.audio` in [video.md](video.md). Music files (MOD, MIDI, ...) render to a Decoder: see
|
||||
@@ -243,6 +243,40 @@ end
|
||||
Roblox has no API to play raw samples, so on Roblox the decoded samples are data only, for example for analysis or
|
||||
visualisers.
|
||||
|
||||
### Lossless: WavPack, Monkey's Audio, TTA
|
||||
|
||||
WavPack (`.wv`), Monkey's Audio (`.ape`) and TTA (`.tta`) open and load like FLAC. Their tags (APEv2) come out in
|
||||
`tags` with lower-case keys. Integer streams also have `readInt`, which returns the exact samples as i32. Every
|
||||
frame of these formats is independent, so `seek` lands on the exact sample.
|
||||
|
||||
```luau
|
||||
local wv = assert(F.audio.open(wvBytes))
|
||||
assert(wv.bitsPerSample == 16 and wv.lossless and wv.tags.title == "Docs Tone")
|
||||
local exact, n = wv:readInt(1024) -- i32 samples, as wvunpack writes them
|
||||
assert(n == 1024 and buffer.readi32(exact, 0) == 0)
|
||||
local ape = assert(F.audio.load(apeBytes)) -- any level, fast .. insane
|
||||
assert(ape.meta.source.format == "ape" and ape.tags.artist == "formats-luau")
|
||||
local tta = assert(F.audio.open(ttaBytes))
|
||||
tta:seek(0.5)
|
||||
assert(math.abs(tta:position() - 0.5) < 1e-6)
|
||||
```
|
||||
|
||||
A hybrid WavPack file holds a lossy stream. Its `.wvc` correction file makes it lossless again. Pass the correction
|
||||
file as `correction`. When you load a file by path, the `.wvc` next to it is found automatically. Without it, the
|
||||
file decodes lossy.
|
||||
|
||||
```luau
|
||||
local lossy = assert(F.audio.open(hybridWvBytes))
|
||||
local full = assert(F.audio.open(hybridWvBytes, { correction = hybridWvcBytes }))
|
||||
assert(lossy.hybrid and not lossy.lossless and full.lossless)
|
||||
```
|
||||
|
||||
<!-- doc:files -->
|
||||
```luau
|
||||
local song = assert(F.audio.load("assets/tone_hybrid.wv")) -- reads assets/tone_hybrid.wvc too
|
||||
assert(song.meta.source.correction == true)
|
||||
```
|
||||
|
||||
## Gotchas
|
||||
|
||||
- `F.ops.audio.downmix(a)` defaults to **2** channels, so a stereo input stays stereo. Use `downmix(a, 1)` for mono.
|
||||
|
||||
Reference in new issue
Block a user