# TTA fixtures (tools/fixtures.py): audio/tta, codecs/audio/Tta. # tests/gen/tta_cases.luau synthetic signals encoded by the reference encoder (ttaenc 3.4.1: 8 / 16 / 24 bits, # 1 / 2 / 3 / 6 channels, odd rates, short and odd lengths, several frames, silence, noise, # full scale) and the ffmpeg FATE sample inside.tta (downloaded at fixture time, cut after 2 # frames, not committed); each with the CRC-32 of `ttaenc -d`'s samples (i32 LE) import importlib.util, os, struct, tempfile, urllib.request, zlib _dir = os.path.dirname(os.path.abspath(__file__)) _spec = importlib.util.spec_from_file_location("_wv", os.path.join(_dir, "wavpack.py")) WV = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(WV) _spec = importlib.util.spec_from_file_location("_ape", os.path.join(_dir, "ape.py")) APE = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(APE) CTX = None TMP = None CASES = [] FATE = "https://fate-suite.ffmpeg.org/lossless-audio/" def emit(name, tta, note, partial=False, keep=None): out = tta + ".out.wav" try: CTX.nix("ttaenc", ["ttaenc", "-d", tta, "-o", out]) except Exception: if not partial: raise rate, ch, bits, fl, s = APE.wav_samples(out) if keep is not None: # a cut file: ttaenc also writes the broken frame; keep the whole ones s = s[:keep * ch] CASES.append({"name": name, "note": note, "data": open(tta, "rb").read(), "rate": rate, "channels": ch, "bits": bits, "float": False, "frames": len(s) // ch, "crc": zlib.crc32(b"".join(struct.pack("