Skip to content

Commit d387fc0

Browse files
committed
Tweaked pad parsing
1 parent a36f417 commit d387fc0

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/Ep133/Parsing.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def parseScenes (raw : ByteArray) : ParseResult Scenes :=
7272

7373
def parsePad (raw : ByteArray) : ParseResult Pad :=
7474
do
75+
require (raw.size = 26)
76+
$ throw ("Pad contains " ++ toString raw.size ++ " bytes instead of 27.")
7577
let playMode ← PlayMode.ofUInt8 raw[23]!
7678
let volume ← Volume.ofUInt8 raw[16]!
7779
let timeStretchMode ← TimeStretchMode.ofUInt8 raw[21]!
@@ -84,7 +86,7 @@ def parsePad (raw : ByteArray) : ParseResult Pad :=
8486
left := getUInt32 0 raw[6]! raw[5]! raw[4]! |> UInt32.toNat
8587
right := getUInt32 0 raw[10]! raw[9]! raw[8]! |> UInt32.toNat
8688
}
87-
let pitch ← Pitch.ofUInt8s raw[17]! raw[26]!
89+
let pitch ← Pitch.ofUInt8s raw[17]! 0 -- raw[26]!
8890
pure
8991
{
9092
raw

src/Ep133Test.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ namespace Examples
6161
, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00
6262
]
6363

64+
def rawPad : ByteArray :=
65+
ByteArray.mk #[
66+
0x00, 0x57, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
67+
, 0x64, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x3c, 0x00
68+
]
69+
6470
end Examples
6571

6672

0 commit comments

Comments
 (0)