#include <Microphone_PDM.h>
|
enum class | OutputSize { UNSIGNED_8
, SIGNED_16
, RAW_SIGNED_16
} |
|
enum class | Range {
RANGE_128 = 0
, RANGE_256
, RANGE_512
, RANGE_1024
,
RANGE_2048
, RANGE_4096
, RANGE_8192
, RANGE_16384
,
RANGE_32768
} |
|
Class used for settings. You will not instantiate one of these; it's a base class of Microphone_PDM_MCU.
There are accessor methods for setting these settings in the Microphone_PDM class.
◆ OutputSize
Configuration for the size of the output data.
Enumerator |
---|
UNSIGNED_8 | Output unsigned 8-bit values (adjusted by PDMRange)
|
SIGNED_16 | Output signed 16-bit values (adjusted by PDMRange) (default)
|
RAW_SIGNED_16 | Output values as signed 16-bit values as returned by MCU (unadjusted)
|
◆ Range
Adjustment value so samples fill most of an 8 or 16 bit output size.
The setting is dependent on your microphone. The Adafruit microphone is 12-bit, so the default value of RANGE_2048 is correct.
Enumerator |
---|
RANGE_128 | From -128 to 127 (8 bits)
|
RANGE_256 | From -256 to 255 (9 bits)
|
RANGE_512 | From -512 to 511 (10 bits)
|
RANGE_1024 | From -1024 to 1023 (11 bits)
|
RANGE_2048 | From -2048 to 2047 (12 bits) (default)
|
RANGE_4096 | From -4096 to 4095 (13 bits)
|
RANGE_8192 | From -8192 to 8191 (14 bits)
|
RANGE_16384 | From -16384 to 16383 (15 bits)
|
RANGE_32768 | From -32768 to 32767 (16 bits) (same as raw mode)
|
◆ Microphone_PDM_Base()
Microphone_PDM_Base::Microphone_PDM_Base |
( |
size_t |
numSamples | ) |
|
|
inlineprotected |
You cannot instantiate one of these, it's only done by the subclass, which is a Microphone_PDM_* MCU-specific class.
- Parameters
-
numSamples | The value of BUFFER_SIZE_SAMPLES defined in the MCU-specific subclass |
◆ copySamplesInternal()
void Microphone_PDM_Base::copySamplesInternal |
( |
const int16_t * |
src, |
|
|
uint8_t * |
dst |
|
) |
| const |
|
protected |
Used internally. Use copySamples() externally.
- Parameters
-
src | Pointer to the internal DMA buffer, which is always 16-bit samples |
dst | Pointer to the destination buffer, which will be 8 or 16-bit samples, depending on outputSize |
Also pays attention to range to determine how much to shift the samples, unless the output size is RAW_SIGNED_16, which does not do any transformation.
src and dst can be the same buffer to transform the data range in place.
◆ copySrcIncrement()
virtual size_t Microphone_PDM_Base::copySrcIncrement |
( |
| ) |
const |
|
inlineprotectedvirtual |
How much to increment src in copySamplesInternal. Used internally.
- Returns
- size_t number of bytes
This is almost always 1. The exception is if you are using 8000 Hz sampling on the nRF52. In this case, every other sample is skipped and the subclass overrides this to return 2.
Reimplemented in Microphone_PDM_nRF52.
◆ getSampleRate()
int Microphone_PDM_Base::getSampleRate |
( |
| ) |
const |
|
inline |
Return the sample rate (16000 or 32000) in samples per second.
- Returns
- int
The documentation for this class was generated from the following files: