TinyModem
Header-only software audio modem library
Loading...
Searching...
No Matches
tinymodem::PcmInput Class Reference

Assembles the PCM frames from the written bytes and provides the samples of the selected channel as float (-1.0 to 1.0). Supports 8, 16 and 32 bit signed samples. More...

#include <ModemBase.h>

Public Member Functions

bool begin (int bits_per_sample, int channels, int channel)
 Defines the format: returns false (and logs the reason) if not supported.
void reset ()
 Drops an incomplete frame.
template<class F>
void write (const uint8_t *data, size_t len, F on_sample)
 Calls on_sample(float) for each complete frame.

Static Public Attributes

static constexpr int MAX_CHANNELS = 8

Protected Member Functions

float sampleValue (const uint8_t *ptr)

Protected Attributes

uint8_t partial [MAX_CHANNELS *4]
int partial_len = 0
int frame_bytes = 2
int sample_offset = 0
int bits = 16

Detailed Description

Assembles the PCM frames from the written bytes and provides the samples of the selected channel as float (-1.0 to 1.0). Supports 8, 16 and 32 bit signed samples.

Member Function Documentation

◆ begin()

bool tinymodem::PcmInput::begin ( int bits_per_sample,
int channels,
int channel )
inline

Defines the format: returns false (and logs the reason) if not supported.

◆ reset()

void tinymodem::PcmInput::reset ( )
inline

Drops an incomplete frame.

◆ sampleValue()

float tinymodem::PcmInput::sampleValue ( const uint8_t * ptr)
inlineprotected

◆ write()

template<class F>
void tinymodem::PcmInput::write ( const uint8_t * data,
size_t len,
F on_sample )
inline

Calls on_sample(float) for each complete frame.

Member Data Documentation

◆ bits

int tinymodem::PcmInput::bits = 16
protected

◆ frame_bytes

int tinymodem::PcmInput::frame_bytes = 2
protected

◆ MAX_CHANNELS

int tinymodem::PcmInput::MAX_CHANNELS = 8
staticconstexpr

◆ partial

uint8_t tinymodem::PcmInput::partial[MAX_CHANNELS *4]
protected

◆ partial_len

int tinymodem::PcmInput::partial_len = 0
protected

◆ sample_offset

int tinymodem::PcmInput::sample_offset = 0
protected

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