Microphone_PDM
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
Microphone_PDM_BufferSampling Class Reference

#include <Microphone_PDM.h>

Public Member Functions

 Microphone_PDM_BufferSampling ()
 
virtual ~Microphone_PDM_BufferSampling ()
 
Microphone_PDM_BufferSamplingwithDurationMs (unsigned long ms)
 
Microphone_PDM_BufferSamplingwithCompletionCallback (std::function< void(uint8_t *buf, size_t bufSize)> completionCallback)
 
Microphone_PDM_BufferSamplingwithReserveHeaderSize (size_t reserveHeaderSize)
 
virtual bool start ()
 
virtual void loop ()
 
virtual bool done () const
 
virtual void preCompletion ()
 

Data Fields

uint8_t * buffer = 0
 
size_t offset = 0
 
size_t bufferSize = 0
 
unsigned long durationMs = 0
 
std::function< void(uint8_t *buf, size_t bufSize)> completionCallback = 0
 
size_t reserveHeaderSize = 0
 
size_t sampleSizeInBytes
 

Detailed Description

Class to configure buffer sampling mode.

This class both configures the settings and also is a container for the sample data.

Allocate this structure with new Microphone_PDM_BufferSampling(), not on the stack! The object ownerships transfers to the Microphone_PDM class which will take care of deleting it.

Member Function Documentation

◆ done()

bool Microphone_PDM_BufferSampling::done ( ) const
virtual

If not using the completion callback, call this to see when the buffering is done.

Returns
true
false

The buffer member is the pointer to the buffer. The bufferSize member is the size in bytes.

◆ preCompletion()

virtual void Microphone_PDM_BufferSampling::preCompletion ( )
inlinevirtual

This methods can be overridden process the data before calling the completion callback.

The Microphone_PDM_BufferSampling_wav class does this to write the wav header.

◆ start()

bool Microphone_PDM_BufferSampling::start ( )
virtual

Start sampling data.

Returns
true
false

◆ withCompletionCallback()

Microphone_PDM_BufferSampling & Microphone_PDM_BufferSampling::withCompletionCallback ( std::function< void(uint8_t *buf, size_t bufSize)>  completionCallback)
inline

Sets a callback function to call when samples are received (optional)

Parameters
completionCallbackFunction or lambda to call when the samples are

◆ withReserveHeaderSize()

Microphone_PDM_BufferSampling & Microphone_PDM_BufferSampling::withReserveHeaderSize ( size_t  reserveHeaderSize)
inline

Sets the reserve space in before the data. This is used to leave space for the wav header.

Parameters
reserveHeaderSize
Returns
Microphone_PDM_BufferSampling&

Field Documentation

◆ buffer

uint8_t* Microphone_PDM_BufferSampling::buffer = 0

Buffer allocated dynamically if bufferSamplingStart() is used. Released by bufferSamplingRelease().

◆ bufferSize

size_t Microphone_PDM_BufferSampling::bufferSize = 0

Size of bufferSamplingBuffer in bytes. Set by bufferSamplingStart().

◆ completionCallback

std::function<void(uint8_t *buf, size_t bufSize)> Microphone_PDM_BufferSampling::completionCallback = 0

Callback to call when buffer is complete

◆ durationMs

unsigned long Microphone_PDM_BufferSampling::durationMs = 0

How long to capture in milliseconds

◆ offset

size_t Microphone_PDM_BufferSampling::offset = 0

Current offset writing to bufferSamplingBuffer if bufferSamplingStart() is being used

◆ reserveHeaderSize

size_t Microphone_PDM_BufferSampling::reserveHeaderSize = 0

Reserves space before the data. This is done by the Microphone_PDM_BufferSampling_wav to leave room for the wav header so the memory does not need to be resized or moved.

◆ sampleSizeInBytes

size_t Microphone_PDM_BufferSampling::sampleSizeInBytes

Filled in during start() so it doesn't need to be retrieved from the Microphone_PDM class every time it's needed (which is often).


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