ws-audio2: Musepack / AC-3 bench lines, docs/guide/audio.md section (+ tools/fixtures/docs_lossy.py inputs), AVI AC-3 track test
This commit is contained in:
1 parent
41b72d9b8a
commit
2d99b9924a
5 files changed
+95
-5
No files matched your search
+24
-2
@@ -99,7 +99,8 @@ the guide's [README](README.md#inputs)). Options:
|
||||
| Option | Formats | Meaning |
|
||||
|---|---|---|
|
||||
| `format` | all | decode as this format (`"mp3"`, `"wav"`, ...) and skip detection |
|
||||
| `maxFrames` | wav, flac, mp3, aiff, au, voc, aac | `Err.LIMIT` past this many frames |
|
||||
| `maxFrames` | wav, flac, mp3, aiff, au, voc, aac, mpc, ac3 | `Err.LIMIT` past this many frames |
|
||||
| `drc` | ac3 | dynamic range control: 0 = off (default), 1 = as the stream says |
|
||||
| `stereo` | opus | downmix surround streams to stereo |
|
||||
|
||||
```luau
|
||||
@@ -189,7 +190,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, mpc (Musepack SV7 / SV8), ac3 (Dolby Digital) |
|
||||
|
||||
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 +244,27 @@ end
|
||||
Roblox has no API to play raw samples, so on Roblox the decoded samples are data only, for example for analysis or
|
||||
visualisers.
|
||||
|
||||
### Musepack and AC-3
|
||||
|
||||
Musepack (`.mpc`, stream versions 7 and 8) decodes gapless, with its APEv2 tags. AC-3 (`.ac3`, Dolby Digital) decodes
|
||||
every channel layout up to 5.1 without downmixing, in WAVE order (FL FR FC LFE SL SR), with dynamic range control off
|
||||
unless `drc` asks for it. The AC-3 tracks of MKV, MP4, MPEG-TS and AVI files open as `v.audio` the same way. Both
|
||||
seek exactly (Musepack SV7 like libmpcdec: 32 frames of pre-roll). E-AC-3 (Dolby Digital Plus) is `Err.UNSUPPORTED`.
|
||||
|
||||
```luau
|
||||
local mpc = assert(F.audio.load(mpcBytes)) -- Musepack: tags, exact length
|
||||
assert(F.detect(mpcBytes) == "mpc" and mpc.tags.title == "Docs Tone")
|
||||
assert(mpc.frames == 44100 and mpc.meta.source.version == 8)
|
||||
local dd = assert(F.audio.open(ac3Bytes)) -- AC-3 5.1: a Decoder like any other
|
||||
assert(dd.channels == 6 and dd.sampleRate == 48000)
|
||||
dd:seek(0.25)
|
||||
local _, n = dd:read(256)
|
||||
assert(n == 256)
|
||||
local stereo = assert(F.ops.audio.downmix(F.audio.load(ac3Bytes))) -- 2 channels, ITU-R BS.775
|
||||
local night = assert(F.audio.load(ac3Bytes, { drc = 1 })) -- the stream's dynamic range gains applied
|
||||
assert(stereo.channels == 2 and night.channels == 6)
|
||||
```
|
||||
|
||||
## 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