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
 

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
}
 

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
 

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

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 

Constructor & Destructor Documentation

◆ WAV() [1/2]

nngn::WAV::WAV ( void )
default

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

◆ WAV() [2/2]

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

Member Function Documentation

◆ bits_per_sample()

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

◆ channels()

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

◆ check()

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

◆ data()

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:

◆ fill()

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

◆ fmt_size()

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

◆ format()

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

◆ n_samples()

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

◆ rate()

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

◆ read()

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

◆ set_channels()

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

◆ set_rate()

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

◆ set_size()

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:

◆ size()

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

◆ subspan()

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

◆ write()

template<typename T >
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:

Member Data Documentation

◆ b

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

◆ HEADER_SIZE

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

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