- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a CY8CPROTO-062-4343W. I am trying to record audio by modifying PCM/PDM sample application in ModusToolbox. I use the following settings in cyhal_pdm_pcm_cfg_t:
- PCM sampling rate: 16 kHz
- mode LEFT channel
- LEFT GAIN 12
- RIGHT GAIN 12
When I play the audio the gain is surprisingly low. The gain settings doesn't have much effect on the intensity. I tried using the function cyhal_pdm_pcm_set_gain without any success. The mic seems to have a sensitivity of -26 dB. What shall I do to get the intensity high? Is there any other settings to change the gain of the audio collected using pcm hal?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
GiVa,
You are correct the standard gain in the USB_Audio_Recorder project is fairly low.
There are a few ways to improve the sensitivity. Some better than others.
Option #1:
In the file audio_in.c change:
/* HAL Config */
const cyhal_pdm_pcm_cfg_t pdm_pcm_cfg =
{
.sample_rate = AUDIO_SAMPLING_RATE_48KHZ,
.decimation_rate = DECIMATION_RATE,
.mode = CYHAL_PDM_PCM_MODE_STEREO,
.word_length = 16, /* bits */
.left_gain = 0, /* dB */
.right_gain = 0, /* dB */
};
to:
/* HAL Config */
const cyhal_pdm_pcm_cfg_t pdm_pcm_cfg =
{
.sample_rate = AUDIO_SAMPLING_RATE_48KHZ,
.decimation_rate = DECIMATION_RATE,
.mode = CYHAL_PDM_PCM_MODE_STEREO,
.word_length = 16, /* bits */
.left_gain = CY_PDM_PCM_GAIN_10_5_DB , /* dB */
.right_gain = CY_PDM_PCM_GAIN_10_5_DB , /* dB */
};
This maximizes the input gain to the max allowed.
Your setting of 12 amplified the gain to +6dB only.
CY_PDM_PCM_GAIN_6_DB = 12U, /**< +6 dB (amplification). */
Option #2:
For each byte received from the PDM to PCM conversion, shift left by:
- 1 to increase the volume by 2x.
- 2 to increase the volume by 4x.
- 3 to increase the volume by 8x.
- ... I think you can see the pattern here.
There are two major downsides to this method.
You may be have a limited output data rate. This is because the CPU must process the incoming data before being sent out the USB.
Amplifying the signal across the board also amplifies the noise.
Maybe someone with more PDM experience than me might come up with a third option.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
giva,
Hi. If you haven't done so already, I recommend downloading the PDM_PCM_Audio example. I've tried it. It has acceptable microphone sensitivity for me. This would be a great starting point for your code.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the quick response. I am using the same pdm pcm audio sample application. The audio was very feeble for me. How much was your audio intensity? I was not able to hear it properly. My speech audio RMS is -40 dB in audacity and the max amplitude is less than 0.1 on a linear scale, which is very feeble if I listen on the laptop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please try to config high pass filter gain from default 0 to 8, see if it helps. Current cyhal_pdm_pcm_init() API miss to config this parameter, you may call Cy_PDM_PCM_Init() API to initialize the high pass filter gain.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
GiVa,
You are correct the standard gain in the USB_Audio_Recorder project is fairly low.
There are a few ways to improve the sensitivity. Some better than others.
Option #1:
In the file audio_in.c change:
/* HAL Config */
const cyhal_pdm_pcm_cfg_t pdm_pcm_cfg =
{
.sample_rate = AUDIO_SAMPLING_RATE_48KHZ,
.decimation_rate = DECIMATION_RATE,
.mode = CYHAL_PDM_PCM_MODE_STEREO,
.word_length = 16, /* bits */
.left_gain = 0, /* dB */
.right_gain = 0, /* dB */
};
to:
/* HAL Config */
const cyhal_pdm_pcm_cfg_t pdm_pcm_cfg =
{
.sample_rate = AUDIO_SAMPLING_RATE_48KHZ,
.decimation_rate = DECIMATION_RATE,
.mode = CYHAL_PDM_PCM_MODE_STEREO,
.word_length = 16, /* bits */
.left_gain = CY_PDM_PCM_GAIN_10_5_DB , /* dB */
.right_gain = CY_PDM_PCM_GAIN_10_5_DB , /* dB */
};
This maximizes the input gain to the max allowed.
Your setting of 12 amplified the gain to +6dB only.
CY_PDM_PCM_GAIN_6_DB = 12U, /**< +6 dB (amplification). */
Option #2:
For each byte received from the PDM to PCM conversion, shift left by:
- 1 to increase the volume by 2x.
- 2 to increase the volume by 4x.
- 3 to increase the volume by 8x.
- ... I think you can see the pattern here.
There are two major downsides to this method.
You may be have a limited output data rate. This is because the CPU must process the incoming data before being sent out the USB.
Amplifying the signal across the board also amplifies the noise.
Maybe someone with more PDM experience than me might come up with a third option.
Len
"Engineering is an Art. The Art of Compromise."