Mic
Mic is used to control the built-in microphone inside the host device. Below is the detailed Mic support for the host:
Controller |
SPM1423 |
ES7210 |
|---|---|---|
AtomS3 |
||
AtomS3 Lite |
||
AtomS3U |
✔ |
|
StampS3 |
||
CoreS3 |
✔ |
|
Core2 |
✔ |
|
TOUGH |
Micropython Example:
pass
UIFLOW2 Example:
pass
class Mic
Important
Methods of the Mic Class heavily rely on M5.begin() and
M5.update() .
All calls to methods of Mic objects should be placed after M5.begin() , and
M5.update() should be called in the main loop.
Methods
- Mic.config([cfg:mic_config_t])
- Mic.config('param')
- Mic.config(param=value)
Get or set the parameters of the Mic object.
When no parameters are passed, it returns an object of
mic_config_t. When amic_config_tobject is passed, Mic sets all supported parameters of the Mic.When passing parameters from the table below, Mic will get or set the passed parameters.
The following parameters are supported:
Parameter
Type
Description
pin_data_in
(integer)
Serial data line of I2S, representing audio data in binary complement.
pin_bck
(integer)
Serial clock line of I2S, corresponding to each bit of digital audio data.
pin_mck
(integer)
Master clock line of I2S. Generally, to better synchronize between systems, increase the MCLK signal, MCLK frequency = 256 * sampling frequency.
pin_ws
(integer)
Frame clock of I2S, used to switch left and right channel data.
sample_rate
(integer)
Target sampling rate of input audio.
stereo
(boolean)
Use stereo output.
over_sampling
(integer)
Number of times to average the sampling.
magnification
(integer)
Multiplier of the input value.
noise_filter_level
(integer)
Coefficient of the previous value used for noise filtering.
use_adc
(boolean)
Use analog input microphone (only pin_data_in is needed).
dma_buf_len
(integer)
DMA buffer length of I2S.
dma_buf_count
(integer)
Number of DMA buffers of I2S.
task_priority
(integer)
Priority of background tasks.
task_pinned_core
(integer)
CPU used by background tasks.
i2s_port
(integer)
I2S port.
UIFLOW2:
Read property:
Python:
Mic.config("pin_data_in")
Set property:
Python:
Mic.config(pin_data_in=1)
- Mic.isRecording() int
Check if Mic is recording. Returns an integer value.
Return values:
0=not recording
1=recording (There’s room in the queue)
2=recording (There’s no room in the queue.)
UIFLOW2:
class mic_config_t
- mic_config_t.pin_data_in: int
Serial data line of I2S, representing audio data in binary complement.
- mic_config_t.pin_bck: int
Serial clock line of I2S, corresponding to each bit of digital audio data.