Arduino library to support the MP23DB01HP digital microphone. Currently, this library works only with the STEVAL-MKBOXPRO board. It requires a STM32 Core equal to or greater than version 2.6.0.
This library can be used to record PCM audio on STEVAL-MKBOXPRO board.
After including PCM.h
, initialize the library by calling PCM.Begin
:
#include <PCM.h>
void setup()
{
// [...]
PCM.Begin();
// [...]
}
Register the data processing callback using PCM.OnReceive
:
void process()
{
Serial.write((const uint8_t *)RecBuff, PCM_REC_BUFF_SIZE * 2U);
}
void setup()
{
// [...]
PCM.OnReceive(process);
// [...]
}
Start recording PCM audio by passing a non-null pointer of a uint16_t[PCM_REC_BUFF_SIZE]
buffer to PCM.Record
:
uint16_t RecBuff[PCM_REC_BUFF_SIZE];
void setup()
{
// [...]
PCM.Record(RecvBuff);
// [...]
}
You can pause a recording by calling PCM.Pause
; in order to resume it, just call PCM.Resume
:
void loop()
{
// [...]
if (cmd == '1') PCM.Pause();
if (cmd == '2') PCM.Resume();
// [...]
}
In order to deinitialize the library, you can execute PCM.End
(if recording, you need first to stop it):
void loop()
{
// [...]
if (cmd == '3') {
if (PCM.GetState() == PCM_AUDIO_IN_STATE_RECORDING) PCM.Stop();
PCM.End();
while(1);
}
// [...]
}
Source files can be found at https://github.com/stm32duino/STEVAL-MKBOXPRO-Audio
Take a look at STEVAL-MKBOXPRO examples applications at https://github.com/stm32duino/STEVAL-MKBOXPRO-Examples