resample is to re-change the sample in software mode,because there is some situation is ,the input sample is 48000Hz,but the alsa sound card only recognize the sound in 44100Hz,so we must do the change ,change the sample of the input sound from 48000Hz to 44100Hz.
an example is in alsa API,there is a function is in /test/pcm_min.c :
00026 if ((err = snd_pcm_set_params(handle,
00027 SND_PCM_FORMAT_U8,
00028 SND_PCM_ACCESS_RW_INTERLEAVED,
00029 1,
00030 48000,
00031 1,
00032 500000)) < 0) { /* 0.5sec */
00033 printf("Playback open error: %sn", snd_strerror(err));
00034 exit(EXIT_FAILURE);
00035 }
and the sixth parameter of snd_pcm_set_params is "1",here "1" represents:
allow resampling
according to definiton of snd_pcm_set_params :
int snd_pcm_set_params | ( | snd_pcm_t * | pcm, | |
snd_pcm_format_t | format, | |||
snd_pcm_access_t | access, | |||
unsigned int | channels, | |||
unsigned int | rate, | |||
int | soft_resample, | |||
unsigned int | latency | |||
) |
Set the hardware and software parameters in a simple way.
- Parameters:
pcm PCM handle format required PCM format access required PCM access channels required PCM channels rate required sample rate in Hz soft_resample 0 = disallow alsa-lib resample stream, 1 = allow resampling latency required overall latency in us (0 = optimum latency for players)
- Returns:
- 0 on success otherwise a negative error code
- Examples:
- /test/pcm_min.c.
中文解释参考: 走进PSP高清世界-专业级PMP制作教学!!
一个是声音取样率的转换resample。需要将声音从48Khz转成44.1Khz。
转载请注明:在路上 » resample of the audio input