Chrispy
High-performance multichannel ADC sampling and audio recording.
Loading...
Searching...
No Matches
WavHeader Struct Reference

Header of a standard PCM WAV file. More...

#include <WavHeader.h>

Public Member Functions

void fill (BitResolution res, uint32_t file_size, uint32_t sample_rate)
 Fill in WAV header fields once all details are known.
 

Data Fields

const char chunk_id [4] = {'R', 'I', 'F', 'F'}
 RIFF chunk identifier ("RIFF").
 
uint32_t chunk_size = 36
 Size of (entire file in bytes - 8 bytes) or (data size + 36) Gets rewritten after data is fully written to file.
 
const char format [4] = {'W', 'A', 'V', 'E'}
 Format identifier (always "WAVE").
 
const char subchunk_id [4] = {'f', 'm', 't', ' '}
 Subchunk ID (always "fmt ").
 
const uint32_t subchunk_size = 16
 Size of the "fmt " subchunk (always 16).
 
const uint16_t audio_format = 1
 Audio format code (PCM = 1).
 
const uint16_t num_channels = 1
 Number of channels.
 
uint32_t sample_rate = 0
 Sampling rate in hertz (samples per second).
 
uint32_t byte_rate = 0
 Byte rate.
 
uint16_t block_align = 2
 Byte alignment of each sample.
 
uint16_t bits_per_sample
 Number of bits per sample.
 
const char sub_chunk_2_id [4] = {'d', 'a', 't', 'a'}
 Subchunk 2 ID.
 
uint32_t sub_chunk_2_size = 0
 Size of data chunk.
 

Detailed Description

Header of a standard PCM WAV file.

Struct contains the metadata in a WAV header in the order it must appear. Must be filled with information specific to a given recording instance before being written.

Member Function Documentation

◆ fill()

void WavHeader::fill ( BitResolution  res,
uint32_t  file_size,
uint32_t  sample_rate 
)

Fill in WAV header fields once all details are known.

Parameters
resBit resolution of samples.
file_sizeSize in bytes of the recording file.
sample_rateSample rate in hertz of audio recording.

Field Documentation

◆ audio_format

const uint16_t WavHeader::audio_format = 1

Audio format code (PCM = 1).

◆ bits_per_sample

uint16_t WavHeader::bits_per_sample

Number of bits per sample.

Rounded to next byte-increment, so 10-bit or 12-bit audio would both become 16-bit.

◆ block_align

uint16_t WavHeader::block_align = 2

Byte alignment of each sample.

NumChannels * BitsPerSample / 8

◆ byte_rate

uint32_t WavHeader::byte_rate = 0

Byte rate.

SampleRate * NumChannels * BitsPerSample / 8.

◆ chunk_id

const char WavHeader::chunk_id[4] = {'R', 'I', 'F', 'F'}

RIFF chunk identifier ("RIFF").

◆ chunk_size

uint32_t WavHeader::chunk_size = 36

Size of (entire file in bytes - 8 bytes) or (data size + 36) Gets rewritten after data is fully written to file.

◆ format

const char WavHeader::format[4] = {'W', 'A', 'V', 'E'}

Format identifier (always "WAVE").

◆ num_channels

const uint16_t WavHeader::num_channels = 1

Number of channels.

1 = Mono, 2 = Stereo With the current implementation, each recording gets its own file and thus makes this mono.

◆ sample_rate

uint32_t WavHeader::sample_rate = 0

Sampling rate in hertz (samples per second).

Filled in later.

◆ sub_chunk_2_id

const char WavHeader::sub_chunk_2_id[4] = {'d', 'a', 't', 'a'}

Subchunk 2 ID.

Always "data".

◆ sub_chunk_2_size

uint32_t WavHeader::sub_chunk_2_size = 0

Size of data chunk.

NumSamples * NumChannels * BitsPerSample/8

◆ subchunk_id

const char WavHeader::subchunk_id[4] = {'f', 'm', 't', ' '}

Subchunk ID (always "fmt ").

◆ subchunk_size

const uint32_t WavHeader::subchunk_size = 16

Size of the "fmt " subchunk (always 16).


The documentation for this struct was generated from the following files: