ws-audio2: AHX and HVL (music/ahx, music/hvl) over codecs/audio/Hively, a port of hvl2wav's replay.c (BSD-3): bit-exact vs hvl2wav
This commit is contained in:
1 parent
4dd6cd1400
commit
848e4bfff6
16 files changed
+2274
No files matched your search
@@ -0,0 +1,36 @@
|
||||
# AHX fixtures (tools/fixtures.py): songs written by tools/fixtures/_hively.py (a hand-made demo over every waveform,
|
||||
# filter / square sweeps, PList commands and effects; random songs) plus karma.ahx from the HivelyTracker source, each
|
||||
# rendered by hvl2wav (nixpkgs#hivelytracker) as the reference.
|
||||
# tests/gen/ahx_cases.luau { { name, data, crc (CRC-32 of hvl2wav's s16le stereo output), head (its first HEAD frames), frames, sampleRate, stereo, subsong, maxDuration?,
|
||||
# prefix (true: hvl2wav ran with a time limit, compare the first frames only) } }
|
||||
import importlib.util, os, zlib
|
||||
|
||||
INPUTS = ["tools/fixtures/_hively.py"]
|
||||
_spec = importlib.util.spec_from_file_location("_hively", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_hively.py"))
|
||||
H = importlib.util.module_from_spec(_spec)
|
||||
_spec.loader.exec_module(H)
|
||||
|
||||
|
||||
HEAD = 11025 # frames of hvl2wav output kept as raw samples (to locate a mismatch); the rest is checked by CRC
|
||||
|
||||
|
||||
def case(ctx, name, data, rate=44100, stereo=0, subsong=0, limit=None):
|
||||
args = ["-f%d" % rate, "-x%d" % stereo, "-s%d" % subsong] + (["-t0:%02d" % limit] if limit else [])
|
||||
pcm, frames = H.hvl2wav(ctx, data, "ahx", args)
|
||||
c = {"name": name, "data": data, "crc": zlib.crc32(pcm), "head": pcm[:HEAD * 4], "frames": frames, "sampleRate": rate, "stereo": stereo,
|
||||
"subsong": subsong, "prefix": limit is not None}
|
||||
if limit:
|
||||
c["maxDuration"] = limit
|
||||
return c
|
||||
|
||||
|
||||
def generate(ctx):
|
||||
rng = ctx.rng(0xA4)
|
||||
demo = H.write_ahx(H.demo_song(False))
|
||||
cases = [case(ctx, "demo", demo), case(ctx, "demo stereo 4", demo, stereo=4),
|
||||
case(ctx, "demo 22050 Hz stereo 2", demo, rate=22050, stereo=2), case(ctx, "demo subsong 1", demo, subsong=1)]
|
||||
for i in range(4):
|
||||
cases.append(case(ctx, "random %d" % i, H.write_ahx(H.random_song(rng, False)), stereo=i))
|
||||
songs = H.source_songs(ctx)
|
||||
cases.append(case(ctx, "karma.ahx", songs["karma.ahx"], stereo=4, limit=3))
|
||||
ctx.emit("ahx_cases", cases)
|
||||
Reference in new issue
Block a user