From 8c75509e13705419456f1b551d1b5917477bb4f5 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Mon, 3 Jul 2023 11:17:50 +0200 Subject: [PATCH] wav: Decode bext chunk --- format/riff/testdata/bext.wav | Bin 0 -> 622 bytes format/riff/testdata/bext.wav.fqtest | 35 +++++++++++++++++++++++++++ format/riff/wav.go | 19 +++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 format/riff/testdata/bext.wav create mode 100644 format/riff/testdata/bext.wav.fqtest diff --git a/format/riff/testdata/bext.wav b/format/riff/testdata/bext.wav new file mode 100644 index 0000000000000000000000000000000000000000..afae247a268ccddeb7ce5ef9cdbd855849957087 GIT binary patch literal 622 zcmWIYbaP8%Vqge&40BCNttg2CvPU`ya&-)F4I)1jj0_A6bq$Pk4U7#;bPY^(4a{I> KF~S%llm-BcCJFrj literal 0 HcmV?d00001 diff --git a/format/riff/testdata/bext.wav.fqtest b/format/riff/testdata/bext.wav.fqtest new file mode 100644 index 00000000..b6ecac64 --- /dev/null +++ b/format/riff/testdata/bext.wav.fqtest @@ -0,0 +1,35 @@ +$ fq dv bext.wav + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: bext.wav (wav) 0x0-0x26d.7 (622) +0x000|52 49 46 46 |RIFF | id: "RIFF" 0x0-0x3.7 (4) +0x000| 66 02 00 00 | f... | size: 614 0x4-0x7.7 (4) +0x000| 57 41 56 45 | WAVE | format: "WAVE" (valid) 0x8-0xb.7 (4) + | | | chunks[0:1]: 0xc-0x26d.7 (610) + | | | [0]{}: chunk 0xc-0x26d.7 (610) +0x000| 62 65 78 74| bext| id: "bext" 0xc-0xf.7 (4) +0x010|5a 02 00 00 |Z... | size: 602 0x10-0x13.7 (4) +0x010| 00 00 00 00 00 00 00 00 00 00 00 00| ............| description: "" 0x14-0x113.7 (256) +0x020|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| +* |until 0x113.7 (256) | | +0x110| 52 45 41 50 45 52 00 00 00 00 00 00| REAPER......| originator: "REAPER" 0x114-0x133.7 (32) +0x120|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| +0x130|00 00 00 00 |.... | +0x130| 00 00 00 00 00 00 00 00 00 00 00 00| ............| originator_reference: "" 0x134-0x153.7 (32) +0x140|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| +0x150|00 00 00 00 |.... | +0x150| 32 30 30 31 2d 30 32 2d 30 33 | 2001-02-03 | originator_date: "2001-02-03" 0x154-0x15d.7 (10) +0x150| 30 34| 04| originator_time: "04-05-06" 0x15e-0x165.7 (8) +0x160|2d 30 35 2d 30 36 |-05-06 | +0x160| 00 00 00 00 | .... | time_reference_low: 0 0x166-0x169.7 (4) +0x160| 00 00 00 00 | .... | time_reference_high: 0 0x16a-0x16d.7 (4) +0x160| 01 00| ..| version: 1 0x16e-0x16f.7 (2) +0x170|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| umid: raw bits 0x170-0x1af.7 (64) +* |until 0x1af.7 (64) | | +0x1b0|00 00 |.. | loudness_value: 0 0x1b0-0x1b1.7 (2) +0x1b0| 00 00 | .. | loudness_range: 0 0x1b2-0x1b3.7 (2) +0x1b0| 00 00 | .. | max_true_peak_level: 0 0x1b4-0x1b5.7 (2) +0x1b0| 00 00 | .. | max_momentary_loudness: 0 0x1b6-0x1b7.7 (2) +0x1b0| 00 00 | .. | max_short_term_loudness: 0 0x1b8-0x1b9.7 (2) +0x1b0| 00 00 00 00 00 00| ......| reserved: raw bits 0x1ba-0x26d.7 (180) +0x1c0|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| +* |until 0x26d.7 (end) (180) | | + | | | coding_history: raw bits 0x26e-NA (0) diff --git a/format/riff/wav.go b/format/riff/wav.go index 653d9181..021be81b 100644 --- a/format/riff/wav.go +++ b/format/riff/wav.go @@ -139,6 +139,25 @@ func wavDecode(d *decode.D) any { d.FieldRawLen("sampler_data", int64(samplerDataBytes)*8) return false, nil + case "bext": + d.FieldUTF8NullFixedLen("description", 256) + d.FieldUTF8NullFixedLen("originator", 32) + d.FieldUTF8NullFixedLen("originator_reference", 32) + d.FieldUTF8NullFixedLen("originator_date", 10) + d.FieldUTF8NullFixedLen("originator_time", 8) + d.FieldU32("time_reference_low") + d.FieldU32("time_reference_high") + d.FieldU16("version") + d.FieldRawLen("umid", 64*8) + d.FieldU16("loudness_value") + d.FieldU16("loudness_range") + d.FieldU16("max_true_peak_level") + d.FieldU16("max_momentary_loudness") + d.FieldU16("max_short_term_loudness") + d.FieldRawLen("reserved", 180*8) + d.FieldRawLen("coding_history", d.BitsLeft()) + return false, nil + default: if riffIsStringChunkID(id) { d.FieldUTF8NullFixedLen("value", int(d.BitsLeft())/8)