From 661e5b7081ba5fb600718980ee263d3e05781ea7 Mon Sep 17 00:00:00 2001 From: Dexrn ZacAttack <60078656+DexrnZacAttack@users.noreply.github.com> Date: Sun, 24 Nov 2024 02:39:22 -0800 Subject: [PATCH] patterns: Added RAD Game Tools BINKA hexpat (#319) * Binka readme * Binka hexpat --- README.md | 1 + patterns/binka.hexpat | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 patterns/binka.hexpat diff --git a/README.md b/README.md index f377f2f..d4b67d4 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi | BLEND | | [`patterns/blend.hexpat`](patterns/blend.hexpat) | Blender Project file | | BMP | `image/bmp` | [`patterns/bmp.hexpat`](patterns/bmp.hexpat) | OS2/Windows Bitmap files | | BIN | | [`patterns/selinux.hexpat`](patterns/selinux.pat) | SE Linux modules | +| BINKA | | [`patterns/binka.hexpat`](patterns/binka.pat) | RAD Game Tools Bink Audio (BINKA) files | | BSON | `application/bson` | [`patterns/bson.hexpat`](patterns/bson.hexpat) | BSON (Binary JSON) format | | bplist | | [`patterns/bplist.hexpat`](patterns/bplist.hexpat) | Apple's binary property list format (bplist) | | BSP | | [`patterns/bsp_goldsrc.hexpat`](patterns/bsp_goldsrc.hexpat) | GoldSrc engine maps format (used in Half-Life 1) | diff --git a/patterns/binka.hexpat b/patterns/binka.hexpat new file mode 100644 index 0000000..fa11f38 --- /dev/null +++ b/patterns/binka.hexpat @@ -0,0 +1,24 @@ +#pragma author DexrnZacAttack +#pragma description RAD Game Tools BINKA (Bink Audio) +#pragma magic [31 46 43 42] @ 0x00 + +import std.string; +import std.math; +import type.magic; + +fn getDuration(u32 duration_ts, u32 sample_rate) { + return float(duration_ts) / float(sample_rate); +}; + +struct Binka { + type::Magic<"1FCB"> magic; + u8; // can't get this to change anything when using ffprobe + u8 channel_count [[name(std::format("Channel Count: {}", this))]]; + u16 sample_rate [[name(std::format("Sample Rate: {}", this))]]; + u32 duration_ts [[name(std::format("Duration: {}s", std::math::floor(getDuration(this, sample_rate))))]]; + u32; + u32 size [[name(std::format("File Size: {} bytes", this))]]; + u8 data[size - 20]; +}; + +Binka binka @ 0x00;