wavex v0.9.3 Wavex.Chunk.Data
Read a data chunk.
Link to this section Summary
Functions
Read a data chunk
Link to this section Types
Link to this section Functions
Link to this function
read(binary)
read(binary()) :: {:ok, t(), binary()} | {:error, Wavex.Error.UnexpectedEOF.t() | Wavex.Error.UnexpectedFourCC.t()}
Read a data chunk.
Examples
Reading a data chunk of size 8
:
iex> Wavex.Chunk.Data.read(<<
...> 0x64, 0x61, 0x74, 0x61, # d a t a
...> 0x08, 0x00, 0x00, 0x00, # 8
...> 0x00, 0x00, 0x00, 0x00, # 0
...> 0x00, 0x00, 0x00, 0x00 # 0
...> >>)
{:ok, %Wavex.Chunk.Data{size: 8, data: <<0, 0, 0, 0, 0, 0, 0, 0>>}, ""}
Caveats
Bytes 1-4 must read "data"
to indicate a data chunk. A different value
results in an error:
iex> Wavex.Chunk.Data.read(<<
...> 0x64, 0x61, 0x74, 0x20, # d a t \s
...> 0x08, 0x00, 0x00, 0x00, # 8
...> 0x00, 0x00, 0x00, 0x00, # 0
...> 0x00, 0x00, 0x00, 0x00 # 0
...> >>)
{:error, %Wavex.Error.UnexpectedFourCC{expected: "data", actual: "dat "}}