wavex v0.1.0 Wavex.FormatChunk

Reading a format chunk.

@formats were taken from github.com/tpn, 2018-05-01, winddk-8.1 / Include / shared / mmreg.h

Link to this section Summary

Functions

Read a format chunk

Validate a format chunk

Link to this section Types

Link to this type t()
t() :: %Wavex.FormatChunk{
  bits_per_sample: pos_integer(),
  block_align: pos_integer(),
  byte_rate: pos_integer(),
  channels: pos_integer(),
  sample_rate: pos_integer()
}

Link to this section Functions

Link to this function read(binary)
read(binary()) :: {:ok, t(), binary()} | {:error, binary()}

Read a format chunk.

Examples

sapp.org, 2018-04-30, Microsoft WAVE soundfile format

iex Wavex.FormatChunk.read(<<
...> # f     m     t     \s
...>   0x66, 0x6d, 0x74, 0x20,
...> # 16
...>   0x10, 0x00, 0x00, 0x00,
...> # 1           2
...>   0x01, 0x00, 0x02, 0x00,
...> # 22050
...>   0x22, 0x56, 0x00, 0x00,
...> # 88200
...>   0x88, 0x58, 0x01, 0x00,
...> # 4           16
...>   0x04, 0x00, 0x10, 0x00,
...> >>)
{:ok,
%Wavex.FormatChunk{
  bits_per_sample: 16,
  block_align: 4,
  byte_rate: 88_200,
  channels: 2,
  sample_rate: 22_050
}, ""}
Link to this function validate(format_chunk)
validate(t()) :: :ok | {:error, binary()}

Validate a format chunk.

Examples

iex> Wavex.FormatChunk.validate(%Wavex.FormatChunk{
...>   bits_per_sample: 16,
...>   block_align: 4,
...>   byte_rate: 88_200,
...>   channels: 2,
...>   sample_rate: 22_050
...> })
:ok