# HE-AAC (SBR) / HE-AACv2 (SBR + PS) fixtures (tools/fixtures.py). fdkaac encodes; ffmpeg's native decoder is the # reference; ffmpeg also remuxes into M4A (implicit signalling), MPEG-TS, MP4 and Matroska (with a tiny MPEG-1 video). # tests/gen/heaac.luau { name, data, container ("adts" | "m4a" | "ts" | "mp4" | "mkv"), signalling ("explicit" | # "implicit"), ps, rate (the output rate), core (the core rate), channels (our output: a mono # core without PS stays mono; ffmpeg's duplicate channel is dropped from ref), frames (ffmpeg's), # ref = ffmpeg's decode as s16le, or same = the name of an earlier case ffmpeg decodes identically } import math, os, random, struct, tempfile PKGS = ["ffmpeg", "fdk-aac-encoder"] INPUTS = [] def music(frames, channels, rate, seed): rng = random.Random(seed) out = [] for i in range(frames): t = i / rate for c in range(channels): v = 0.2 * math.sin(2 * math.pi * (220 * (c + 1)) * t + 3 * math.sin(2 * math.pi * 5 * t)) v += 0.1 * math.sin(2 * math.pi * 660 * t) + 0.06 * math.sin(2 * math.pi * 1320.5 * t + c) v += 0.04 * math.sin(2 * math.pi * (5000 + 300 * c) * t) + 0.03 * math.sin(2 * math.pi * (9000 + 700 * c) * t) v += 0.08 * (rng.random() * 2 - 1) if (i // (rate // 8)) % 3 == 1: v += 0.12 * (rng.random() * 2 - 1) if i % (rate // 3) < 40: v += 0.5 * (1 - (i % (rate // 3)) / 40) * (1 if (i // 7) % 2 else -1) out.append(max(-32768, min(32767, int(round(v * 20000))))) return out def wav(ints, ch, rate): data = struct.pack("<%dh" % len(ints), *ints) fmt = struct.pack("