wavex v0.2.5 Wavex
Reading PCM WAVE files.
Link to this section Summary
Functions
Read a PCM WAVE file
Link to this section Types
Link to this type
t()
t() :: %Wavex{ data_chunk: Wavex.DataChunk.t(), format_chunk: Wavex.FormatChunk.t(), riff_header: Wavex.RIFFHeader.t() }
Link to this section Functions
Read a PCM WAVE file.
Examples
sapp.org, 2018-04-30, Microsoft WAVE soundfile format
iex Wavex.read(<<
...> 0x52, 0x49, 0x46, 0x46, # R I F F
...> 0x24, 0x08, 0x00, 0x00, # 38
...> 0x57, 0x41, 0x56, 0x45, # W A V E
...> 0x66, 0x6D, 0x74, 0x20, # f m t \s
...> 0x10, 0x00, 0x00, 0x00, # 16
...> 0x01, 0x00, 0x02, 0x00, # 1 2
...> 0x22, 0x56, 0x00, 0x00, # 22050
...> 0x88, 0x58, 0x01, 0x00, # 88200
...> 0x04, 0x00, 0x10, 0x00, # 4 16
...> 0x64, 0x61, 0x74, 0x61, # d a t a
...> 0x02, 0x00, 0x00, 0x00, # 2
...> 0x00, 0x00, 0x00, 0x00, # 0
...> 0x00, 0x00, 0x00, 0x00 # 0
...> >>)
{:ok,
%Wavex{
data_chunk: %Wavex.DataChunk{
data: <<0, 0, 0, 0, 0, 0, 0, 0>>,
size: 2
},
format_chunk: %Wavex.FormatChunk{
bits_per_sample: 16,
block_align: 4,
byte_rate: 88_200,
channels: 2,
sample_rate: 22_050
},
riff_header: %Wavex.RIFFHeader{size: 2084}
}}
iex> Wavex.read(<<
...> 0x52, 0x49, 0x46, 0x46, # R I F F
...> 0x24, 0x08, 0x00, 0x00, # 38
...> 0x57, 0x41, 0x56, 0x45, # W A V E
...> 0x66, 0x6D, 0x74, 0x20, # f m t \s
...> 0x10, 0x00, 0x00, 0x00, # 16
...> 0x01, 0x00, 0x01, 0x00, # 1 1
...> 0x11, 0x2B, 0x00, 0x00, # 11025
...> 0x22, 0x56, 0x00, 0x00, # 22050
...> 0x02, 0x00, 0x10, 0x00, # 2 16
...> 0x64, 0x61, 0x74, 0x61, # d a t a
...> 0x02, 0x00, 0x00, 0x00, # 2
...> 0x00, 0x00, 0xFE, 0xFF # 0 0 254 255
...> >>)
{:ok,
%Wavex{
data_chunk: %Wavex.DataChunk{data: <<0, 0, 254, 255>>, size: 2},
format_chunk: %Wavex.FormatChunk{
bits_per_sample: 16,
block_align: 2,
byte_rate: 22050,
channels: 1,
sample_rate: 11025
},
riff_header: %Wavex.RIFFHeader{size: 2084}
}}