gpt4 book ai didi

linux - ALSA dmix 插件和采样率问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:30:50 24 4
gpt4 key购买 nike

我在一个嵌入式项目上使用 ALSA dmix 插件,并通过使用 mpg321-alsa 播放它们来混合 mp3 文件。在我的 asound.conf 中,我将我的 dmix 采样率设置为 44100Hz。

如果我尝试播放以 44100Hz(或平均分为 44100Hz 的速率)以外的速率采样的任何 mp3 文件,那么要么音频质量下降,要么更糟的是文件的开头被忽略。这有一个随机方面:如果我创建一个长度为 300 毫秒的音频文件并通过 mpg321-alsa 播放它,那么有时它播放正常,有时根本没有声音。

这是 dmix 的已知问题吗?除了重新采样 mp3 文件之外,是否有任何解决方法?

最佳答案

参见 ALSA plugin documentation .

Note that the dmix plugin itself supports only a single configuration. That is, it supports only the fixed rate (default 48000), format (S16), channels (2), and period_time (125000). For using other configuration, you have to set the value explicitly in the slave PCM definition. The rate, format and channels can be covered by an additional plug plugin, but there is only one base configuration, anyway.

作为示例(修改以满足您的需要),

pcm.dsp0 {
type plug
slave.pcm "asym0"
slave.rate 44100
}

pcm.asym0 {
type asym
playback.pcm "dmix0"
capture.pcm "dsnoop0"
}

pcm.dmix0 {
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm {
type hw
card 0
device 0
}
period_time 0
period_size 1024
buffer_size 65536
format "S16_LE"
periods 128
rate 44100
}
}

pcm.dsnoop0 {
type dsnoop
ipc_key 1025
ipc_perm 0666
slave.pcm {
type hw
card 0
device 0
}
}

关于linux - ALSA dmix 插件和采样率问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1715770/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com