KaitaiStructWorkshop/05_data.ksy

78 lines
1.6 KiB
Plaintext

meta:
id: wav
file-extension: wav
encoding: ascii
endian: le
seq:
- id: magic
type: str
size: 4
- id: size
type: u4
- id: wave_str
type: str
size: 4
- id: sections
type: section
repeat: eos
instances: {}
types:
section:
seq:
- id: name
type: str
size: 4
- id: size
type: u4
- id: content
size: size
type:
switch-on: name
cases:
'"fmt "': fmt
'"data"': data
fmt:
seq:
- id: type
type: u2
- id: channels
type: u2
- id: samplerate
type: u4
- id: datarate
type: u4
doc: Might also be datarate per channel
- id: bytes_per_sample
type: u2
- id: bits_per_unit
type: u2
instances:
combined_type:
value: type * 100 + bits_per_unit
data:
seq:
- id: content
type: sample
repeat: eos
types:
sample:
seq:
- id: data
type:
# I don't mention this in the video, but you
# can use arithmetic expressions here as well
# I just did this to show value instances :)
switch-on: _root.sections[0].content.\
as<fmt>.combined_type
cases:
332: f4
108: u1
116: s2
132: s4
repeat: expr
repeat-expr: _root.sections[0].content.\
as<fmt>.channels
enums: {}
doc: Hello, world
doc-ref: https://example.com