nngn
Loading...
Searching...
No Matches
nngn::WAV Class Reference

A non-owning wrapper for a byte buffer containing a WAV file. More...

#include <wav.h>

Classes

struct  segment
 

Public Member Functions

 WAV (void)=default
 Constructs an empty object, must be initialized before it is used.
 
constexpr WAV (std::span< std::byte > buffer)
 
constexpr u32 fmt_size (void) const
 
constexpr u16 format (void) const
 
constexpr u16 channels (void) const
 
constexpr u32 rate (void) const
 
constexpr u16 bits_per_sample (void) const
 
constexpr std::size_t n_samples (void) const
 
constexpr void set_size (u32 s) const
 
constexpr void set_channels (u16 c) const
 
constexpr void set_rate (u32 r) const
 
constexpr void fill (void) const
 
constexpr std::span< std::byte > data (void) const
 
bool check (void) const
 
 WAV (void)=default
 Constructs an empty object, must be initialized before it is used.
 
constexpr WAV (std::span< std::byte > buffer)
 
constexpr u32 fmt_size (void) const
 
constexpr u16 format (void) const
 
constexpr u16 channels (void) const
 
constexpr u32 rate (void) const
 
constexpr u16 bits_per_sample (void) const
 
constexpr std::size_t n_samples (void) const
 
constexpr void set_size (u32 s) const
 
constexpr void set_channels (u16 c) const
 
constexpr void set_rate (u32 r) const
 
constexpr void fill (void) const
 
constexpr std::span< std::byte > data (void) const
 
bool check (void) const
 

Static Public Attributes

static constexpr std::size_t HEADER_SIZE = 44
 

Private Types

enum class  offset : std::size_t {
  RIFF_SEG = 0 , SEG_SIZE = 4 , WAVE_SEG = 8 , FMT_SEG = 12 ,
  FMT_SIZE = 16 , FORMAT = 20 , CHANNELS = 22 , RATE = 24 ,
  BYTES_PER_SEC = 28 , BLOCK_ALIGN = 32 , BITS_PER_SAMPLE = 34 , DATA_SEG = 36 ,
  DATA_SIZE = 40 , DATA = HEADER_SIZE , RIFF_SEG = 0 , SEG_SIZE = 4 ,
  WAVE_SEG = 8 , FMT_SEG = 12 , FMT_SIZE = 16 , FORMAT = 20 ,
  CHANNELS = 22 , RATE = 24 , BYTES_PER_SEC = 28 , BLOCK_ALIGN = 32 ,
  BITS_PER_SAMPLE = 34 , DATA_SEG = 36 , DATA_SIZE = 40 , DATA = HEADER_SIZE
}
 
enum class  offset : std::size_t {
  RIFF_SEG = 0 , SEG_SIZE = 4 , WAVE_SEG = 8 , FMT_SEG = 12 ,
  FMT_SIZE = 16 , FORMAT = 20 , CHANNELS = 22 , RATE = 24 ,
  BYTES_PER_SEC = 28 , BLOCK_ALIGN = 32 , BITS_PER_SAMPLE = 34 , DATA_SEG = 36 ,
  DATA_SIZE = 40 , DATA = HEADER_SIZE , RIFF_SEG = 0 , SEG_SIZE = 4 ,
  WAVE_SEG = 8 , FMT_SEG = 12 , FMT_SIZE = 16 , FORMAT = 20 ,
  CHANNELS = 22 , RATE = 24 , BYTES_PER_SEC = 28 , BLOCK_ALIGN = 32 ,
  BITS_PER_SAMPLE = 34 , DATA_SEG = 36 , DATA_SIZE = 40 , DATA = HEADER_SIZE
}
 

Private Member Functions

constexpr std::span< std::byte > subspan (offset o, std::size_t n) const
 
template<typename T >
constexpr T read (offset o) const
 
template<typename T >
constexpr void write (offset o, const T &x) const
 
constexpr std::size_t size (void) const
 
constexpr std::span< std::byte > subspan (offset o, std::size_t n) const
 
template<typename T >
constexpr T read (offset o) const
 
template<typename T >
constexpr void write (offset o, const T &x) const
 
constexpr std::size_t size (void) const
 

Private Attributes

std::span< std::byte > b = {}
 

Detailed Description

A non-owning wrapper for a byte buffer containing a WAV file.

Member Enumeration Documentation

◆ offset [1/2]

enum class nngn::WAV::offset : std::size_t
strongprivate
Enumerator
RIFF_SEG 
SEG_SIZE 
WAVE_SEG 
FMT_SEG 
FMT_SIZE 
FORMAT 
CHANNELS 
RATE 
BYTES_PER_SEC 
BLOCK_ALIGN 
BITS_PER_SAMPLE 
DATA_SEG 
DATA_SIZE 
DATA 
RIFF_SEG 
SEG_SIZE 
WAVE_SEG 
FMT_SEG 
FMT_SIZE 
FORMAT 
CHANNELS 
RATE 
BYTES_PER_SEC 
BLOCK_ALIGN 
BITS_PER_SAMPLE 
DATA_SEG 
DATA_SIZE 
DATA 

◆ offset [2/2]

enum class nngn::WAV::offset : std::size_t
strongprivate
Enumerator
RIFF_SEG 
SEG_SIZE 
WAVE_SEG 
FMT_SEG 
FMT_SIZE 
FORMAT 
CHANNELS 
RATE 
BYTES_PER_SEC 
BLOCK_ALIGN 
BITS_PER_SAMPLE 
DATA_SEG 
DATA_SIZE 
DATA 
RIFF_SEG 
SEG_SIZE 
WAVE_SEG 
FMT_SEG 
FMT_SIZE 
FORMAT 
CHANNELS 
RATE 
BYTES_PER_SEC 
BLOCK_ALIGN 
BITS_PER_SAMPLE 
DATA_SEG 
DATA_SIZE 
DATA 

Constructor & Destructor Documentation

◆ WAV() [1/4]

nngn::WAV::WAV ( void  )
default

Constructs an empty object, must be initialized before it is used.

◆ WAV() [2/4]

constexpr nngn::WAV::WAV ( std::span< std::byte >  buffer)
inlineexplicitconstexpr

◆ WAV() [3/4]

nngn::WAV::WAV ( void  )
default

Constructs an empty object, must be initialized before it is used.

◆ WAV() [4/4]

constexpr nngn::WAV::WAV ( std::span< std::byte >  buffer)
explicitconstexpr

Member Function Documentation

◆ bits_per_sample() [1/2]

constexpr u16 nngn::WAV::bits_per_sample ( void  ) const
inlineconstexpr
Here is the caller graph for this function:

◆ bits_per_sample() [2/2]

constexpr u16 nngn::WAV::bits_per_sample ( void  ) const
constexpr

◆ channels() [1/2]

constexpr u16 nngn::WAV::channels ( void  ) const
inlineconstexpr
Here is the caller graph for this function:

◆ channels() [2/2]

constexpr u16 nngn::WAV::channels ( void  ) const
constexpr

◆ check() [1/2]

bool nngn::WAV::check ( void  ) const
Here is the call graph for this function:

◆ check() [2/2]

bool nngn::WAV::check ( void  ) const

◆ data() [1/2]

constexpr std::span< std::byte > nngn::WAV::data ( void  ) const
inlineconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ data() [2/2]

constexpr std::span< std::byte > nngn::WAV::data ( void  ) const
constexpr

◆ fill() [1/2]

constexpr void nngn::WAV::fill ( void  ) const
inlineconstexpr
Here is the call graph for this function:

◆ fill() [2/2]

constexpr void nngn::WAV::fill ( void  ) const
constexpr

◆ fmt_size() [1/2]

constexpr u32 nngn::WAV::fmt_size ( void  ) const
inlineconstexpr
Here is the caller graph for this function:

◆ fmt_size() [2/2]

constexpr u32 nngn::WAV::fmt_size ( void  ) const
constexpr

◆ format() [1/2]

constexpr u16 nngn::WAV::format ( void  ) const
inlineconstexpr
Here is the caller graph for this function:

◆ format() [2/2]

constexpr u16 nngn::WAV::format ( void  ) const
constexpr

◆ n_samples() [1/2]

constexpr std::size_t nngn::WAV::n_samples ( void  ) const
inlineconstexpr
Here is the call graph for this function:

◆ n_samples() [2/2]

constexpr std::size_t nngn::WAV::n_samples ( void  ) const
constexpr

◆ rate() [1/2]

constexpr u32 nngn::WAV::rate ( void  ) const
inlineconstexpr
Here is the caller graph for this function:

◆ rate() [2/2]

constexpr u32 nngn::WAV::rate ( void  ) const
constexpr

◆ read() [1/2]

template<typename T >
constexpr T nngn::WAV::read ( offset  o) const
constexprprivate
Here is the call graph for this function:

◆ read() [2/2]

template<typename T >
constexpr T nngn::WAV::read ( offset  o) const
constexprprivate

◆ set_channels() [1/2]

constexpr void nngn::WAV::set_channels ( u16  c) const
inlineconstexpr
Here is the call graph for this function:

◆ set_channels() [2/2]

constexpr void nngn::WAV::set_channels ( u16  c) const
constexpr

◆ set_rate() [1/2]

constexpr void nngn::WAV::set_rate ( u32  r) const
inlineconstexpr
Here is the call graph for this function:

◆ set_rate() [2/2]

constexpr void nngn::WAV::set_rate ( u32  r) const
constexpr

◆ set_size() [1/2]

constexpr void nngn::WAV::set_size ( u32  s) const
inlineconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_size() [2/2]

constexpr void nngn::WAV::set_size ( u32  s) const
constexpr

◆ size() [1/2]

constexpr std::size_t nngn::WAV::size ( void  ) const
inlineconstexprprivate
Here is the caller graph for this function:

◆ size() [2/2]

constexpr std::size_t nngn::WAV::size ( void  ) const
constexprprivate

◆ subspan() [1/2]

constexpr std::span< std::byte > nngn::WAV::subspan ( offset  o,
std::size_t  n 
) const
inlineconstexprprivate
Here is the caller graph for this function:

◆ subspan() [2/2]

constexpr std::span< std::byte > nngn::WAV::subspan ( offset  o,
std::size_t  n 
) const
constexprprivate

◆ write() [1/2]

template<typename T >
constexpr void nngn::WAV::write ( offset  o,
const T x 
) const
constexprprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [2/2]

template<typename T >
constexpr void nngn::WAV::write ( offset  o,
const T x 
) const
constexprprivate

Member Data Documentation

◆ b

std::span< std::byte > nngn::WAV::b = {}
private

◆ HEADER_SIZE

static constexpr std::size_t nngn::WAV::HEADER_SIZE = 44
staticconstexpr

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