wavex v0.4.12 Wavex.DataChunk
Reading a data chunk.
A data chunk normally contains:
- a
"data"
FourCC, - the size of the actual audio data,
- the actual audio data.
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()} | {:error, Wavex.Error.UnexpectedEOF.t() | Wavex.Error.UnexpectedFourCC.t()}
Read a data chunk.
Examples
iex> Wavex.DataChunk.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.DataChunk{size: 8, data: <<0, 0, 0, 0, 0, 0, 0, 0>>}}
Caveat
“data” FourCC
Bytes 1-4 must read "data"
to indicate a data chunk. A different value
results in an error.
iex> Wavex.DataChunk.read(<<"dat ", 2, 0, 0>>)
{:error, %Wavex.Error.UnexpectedFourCC{expected: "data", actual: "dat "}}