ws-audio2: merge ws/audio2-lossless (WavPack, Monkey's Audio, TTA, ApeTag)
codecs/audio/Stream: both branches extended pull(): buffer pcm (adpcm) and scale / ints (lossless); combined.
This commit is contained in:
commit
f6188764b8
26 files changed
+4728
-6
No files matched your search
+35
-1
@@ -192,7 +192,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), qoa, adx, vag, adpcm (raw IMA / MS) | aac (ADTS), m4a / caf AAC, mpc (Musepack SV7 / SV8), ac3 (Dolby Digital), brstm / bcstm / bfstm, KVAG, wav / aifc / caf IMA and MS ADPCM |
|
||||
| wav (+ RF64), flac (+ Ogg FLAC), mp3 / mp2, vorbis (.ogg), opus, aiff / aifc, au, voc, caf, m4a (ALAC), qoa, adx, vag, adpcm (raw IMA / MS) | aac (ADTS), m4a / caf AAC, mpc (Musepack SV7 / SV8), ac3 (Dolby Digital), brstm / bcstm / bfstm, KVAG, wav / aifc / caf IMA and MS ADPCM, 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
|
||||
@@ -301,6 +301,40 @@ Read only: Nintendo BRSTM / BCSTM / BFSTM (DSP ADPCM or PCM; `F.detect` names th
|
||||
inside WAV (IMA, MS), AIFF-C and CAF (ima4). Decoding is bit-exact with vgmstream (ADX, VAG, BRSTM) and ffmpeg
|
||||
(IMA, MS, ima4, QOA). Seeking is exact everywhere: the decoders keep the predictor state of every block they pass.
|
||||
|
||||
### 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