Comments and stuff
This commit is contained in:
parent
50accfafa1
commit
630d94c1ee
|
@ -7,11 +7,16 @@ seq:
|
||||||
- id: magic
|
- id: magic
|
||||||
type: str
|
type: str
|
||||||
size: 4
|
size: 4
|
||||||
|
# We don't actually handle invalid files here.
|
||||||
|
# If we wanted, we could also use this key:
|
||||||
|
# contents: "RIFF"
|
||||||
|
# But then we could not use the type key...
|
||||||
- id: size
|
- id: size
|
||||||
type: u4
|
type: u4
|
||||||
- id: wave_str
|
- id: wave_str
|
||||||
type: str
|
type: str
|
||||||
size: 4
|
size: 4
|
||||||
|
# Same as with the magic field
|
||||||
instances: {}
|
instances: {}
|
||||||
types: {}
|
types: {}
|
||||||
enums: {}
|
enums: {}
|
||||||
|
|
|
@ -14,6 +14,7 @@ seq:
|
||||||
size: 4
|
size: 4
|
||||||
- id: sections
|
- id: sections
|
||||||
type: section
|
type: section
|
||||||
|
# Repeat until the end of the stream
|
||||||
repeat: eos
|
repeat: eos
|
||||||
instances: {}
|
instances: {}
|
||||||
types:
|
types:
|
||||||
|
@ -26,6 +27,8 @@ types:
|
||||||
type: u4
|
type: u4
|
||||||
- id: content
|
- id: content
|
||||||
size: size
|
size: size
|
||||||
|
# No type yet - just read in a byte array of the given
|
||||||
|
# size, which refers to the size field just before
|
||||||
enums: {}
|
enums: {}
|
||||||
doc: Hello, world
|
doc: Hello, world
|
||||||
doc-ref: https://example.com
|
doc-ref: https://example.com
|
||||||
|
|
|
@ -59,6 +59,9 @@ types:
|
||||||
seq:
|
seq:
|
||||||
- id: data
|
- id: data
|
||||||
type:
|
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.\
|
switch-on: _root.sections[0].content.\
|
||||||
as<fmt>.combined_type
|
as<fmt>.combined_type
|
||||||
cases:
|
cases:
|
||||||
|
|
33
08_enums.ksy
33
08_enums.ksy
|
@ -8,24 +8,32 @@ seq:
|
||||||
# Could assert using contents here, but
|
# Could assert using contents here, but
|
||||||
# just make sections conditional later
|
# just make sections conditional later
|
||||||
#contents: "RIFF"
|
#contents: "RIFF"
|
||||||
|
|
||||||
|
# Not using contents means we can give this a type
|
||||||
|
# Big endian, because we store the 4-character string
|
||||||
|
# 'RIFF' (0x52 0x49 0x46 0x46) as enum value 0x52494646
|
||||||
type: u4be
|
type: u4be
|
||||||
|
|
||||||
|
# Integers can have an optional enum key
|
||||||
enum: fourcc
|
enum: fourcc
|
||||||
- id: size
|
- id: size
|
||||||
type: u4
|
type: u4
|
||||||
- id: wave_str
|
- id: wave_str
|
||||||
|
# Same as the magic field
|
||||||
#contents: "WAVE"
|
#contents: "WAVE"
|
||||||
type: u4be
|
type: u4be
|
||||||
enum: fourcc
|
enum: fourcc
|
||||||
- id: sections
|
- id: sections
|
||||||
type: section
|
type: section
|
||||||
repeat: eos
|
repeat: eos
|
||||||
|
# Only try to decode this if this looks like a wave file
|
||||||
if: 'magic == fourcc::riff and wave_str == fourcc::wave'
|
if: 'magic == fourcc::riff and wave_str == fourcc::wave'
|
||||||
instances: {}
|
instances: {}
|
||||||
types:
|
types:
|
||||||
section:
|
section:
|
||||||
seq:
|
seq:
|
||||||
- id: name
|
- id: name
|
||||||
type: u4be # Big endian!
|
type: u4be # Big endian, same reason as above
|
||||||
enum: fourcc
|
enum: fourcc
|
||||||
- id: size
|
- id: size
|
||||||
type: u4
|
type: u4
|
||||||
|
@ -43,7 +51,7 @@ types:
|
||||||
seq:
|
seq:
|
||||||
- id: type
|
- id: type
|
||||||
type: u2
|
type: u2
|
||||||
enum: encoding_type_enum
|
enum: encoding
|
||||||
- id: channels
|
- id: channels
|
||||||
type: u2
|
type: u2
|
||||||
- id: samplerate
|
- id: samplerate
|
||||||
|
@ -61,24 +69,21 @@ types:
|
||||||
type:
|
type:
|
||||||
switch-on: _root.sections[0].name
|
switch-on: _root.sections[0].name
|
||||||
cases:
|
cases:
|
||||||
'fourcc::fmt': sample(_root.sections[0].content.as<fmt>.type, _root.sections[0].content.as<fmt>.bits_per_unit)
|
'fourcc::fmt': sample(_root.sections[0].content.as<fmt>)
|
||||||
_: u1
|
_: u1
|
||||||
repeat: eos
|
repeat: eos
|
||||||
types:
|
types:
|
||||||
sample:
|
sample:
|
||||||
params:
|
params:
|
||||||
- id: encoding_type
|
- id: fmt
|
||||||
type: u2
|
type: fmt
|
||||||
enum: encoding_type_enum
|
|
||||||
- id: encoding_size
|
|
||||||
type: u2
|
|
||||||
seq:
|
seq:
|
||||||
- id: data
|
- id: data
|
||||||
type:
|
type:
|
||||||
switch-on: encoding_type
|
switch-on: fmt.type
|
||||||
cases:
|
cases:
|
||||||
'encoding_type_enum::float': float_type
|
'encoding::float': float_type
|
||||||
'encoding_type_enum::int': int_type
|
'encoding::int': int_type
|
||||||
repeat: expr
|
repeat: expr
|
||||||
repeat-expr: _root.sections[0].content.\
|
repeat-expr: _root.sections[0].content.\
|
||||||
as<fmt>.channels
|
as<fmt>.channels
|
||||||
|
@ -87,7 +92,7 @@ types:
|
||||||
seq:
|
seq:
|
||||||
- id: data
|
- id: data
|
||||||
type:
|
type:
|
||||||
switch-on: _parent.encoding_size
|
switch-on: _parent.fmt.bits_per_unit
|
||||||
cases:
|
cases:
|
||||||
32: f4
|
32: f4
|
||||||
64: f8
|
64: f8
|
||||||
|
@ -95,7 +100,7 @@ types:
|
||||||
seq:
|
seq:
|
||||||
- id: data
|
- id: data
|
||||||
type:
|
type:
|
||||||
switch-on: _parent.encoding_size
|
switch-on: _parent.fmt.bits_per_unit
|
||||||
cases:
|
cases:
|
||||||
8: u1
|
8: u1
|
||||||
16: s2
|
16: s2
|
||||||
|
@ -142,7 +147,7 @@ enums:
|
||||||
0x5045414b: 'peak'
|
0x5045414b: 'peak'
|
||||||
0x64617461: 'data'
|
0x64617461: 'data'
|
||||||
0x4c495354: 'list'
|
0x4c495354: 'list'
|
||||||
encoding_type_enum:
|
encoding:
|
||||||
1: 'int'
|
1: 'int'
|
||||||
3: 'float'
|
3: 'float'
|
||||||
doc: Hello, world
|
doc: Hello, world
|
||||||
|
|
Loading…
Reference in New Issue
Block a user