最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

resample of the audio input

工作和技术 crifan 2650浏览 0评论

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_tformat,
snd_pcm_access_taccess,
unsigned intchannels,
unsigned intrate,
intsoft_resample,
unsigned intlatency
)

Set the hardware and software parameters in a simple way.

Parameters:
pcmPCM handle
formatrequired PCM format
accessrequired PCM access
channelsrequired PCM channels
raterequired sample rate in Hz
soft_resample0 = disallow alsa-lib resample stream, 1 = allow resampling
latencyrequired 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

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.192 seconds, using 22.12MB memory