![]() |
SmartCradle v1
Baby smart cradle
|
Microphone module header. More...

Go to the source code of this file.
Macros | |
| #define | ERR_OPEN 12 |
| #define | ERR_READ 15 |
Functions | |
| int | startRecording () |
| Records a 2 second .wav audio from microphone. More... | |
| int | processAudio (double *loudness) |
| Processes the audio to check whether the baby is crying. More... | |
Microphone module header.
Definition in file microphone.h.
| #define ERR_OPEN 12 |
Error when opening audio file
Definition at line 13 of file microphone.h.
| #define ERR_READ 15 |
Error when reading audio file
Definition at line 14 of file microphone.h.
| int processAudio | ( | double * | loudness | ) |
Processes the audio to check whether the baby is crying.
The loudness of the audio samples is calculated and, if the predefined threshold is passed, a counter is incremented. At 3 consecutive samples that have breached the threshold, it is considered that the baby is crying.
Definition at line 73 of file microphone.c.
| int startRecording | ( | ) |
Records a 2 second .wav audio from microphone.
Recording is possible by using FFmpeg. The parameters used are: -f alsa : force audio input device to be of ALSA -ac 1 : set audio channel to 1 -ar 44100 : set audio sampling rate to 44100 Hz -i plughw:0,0 : select the audio card referencing the microphone -c:a copy : set audio codec to copy (copies the frames directly instead of decoding/filtering/encoding) -t 2 : recording duration -y : overwrite output files audiorecord.wav output file
Definition at line 18 of file microphone.c.