在 Audacity 等应用程序中播放和录制期间支持多种采样率

在 Audacity 等应用程序中播放和录制期间支持多种采样率

这就是我定义声卡通道的方式.asoundrc

pcm.!default {
    type plug
    slave {
       pcm "hw:1,0"
    }
}

ctl.!default { 
    type hw
    card 1
}

pcm_slave.usb_1 {
    pcm "hw:1,0"
    rate 44100
    channels 8
    buffer_size 4096
    period_size 1024
}

pcm.outch1 {
    type dshare
    ipc_key 1111
    slave usb_1
    bindings [ 0 ]
    hint.description "USB output/playback channel 1 (from output port 1)"
}

pcm.inch1 {
    type dsnoop
    ipc_key 1111
    slave usb_1
    bindings [ 0 ]
    hint.description "USB input/capture channel 1 (from input port 1)"
}

虽然上述aplay与和配合使用效果很好arecord终端中的函数/命令,尝试播放 8k 音频样本时Audacity会抛出以下错误:

大胆错误

当我检查菜单Audio device info中的选项Help(帮助-->音频设备选项)时,我看到以下内容:

Device ID: 2
Device name: USB Audio (hw:1,0)
Host name: ALSA
Recording channels: 8
Playback channels: 8
Low Recording Latency: 0.008707
Low Playback Latency: 0.008707
High Recording Latency: 0.034830
High Playback Latency: 0.034830
Supported Rates:
    44100
    48000
    88200
    96000
==============================
Device ID: 10
Device name: outch1
Host name: ALSA
Recording channels: 0
Playback channels: 1
Low Recording Latency: -1.000000
Low Playback Latency: 0.023220
High Recording Latency: -1.000000
High Playback Latency: 0.023220
Supported Rates:
    44100
==============================
Device ID: 11
Device name: inch1
Host name: ALSA
Recording channels: 1
Playback channels: 0
Low Recording Latency: 0.023220
Low Playback Latency: -1.000000
High Recording Latency: 0.023220
High Playback Latency: -1.000000
Supported Rates:
==============================

正如我们所看到的,8000或者16000不是Supported Rate来自音频设备信息。那么,抛出错误的原因就很清楚了。

那么,如何以及在哪里添加/设置(.asoundrc也许修改我的?)这些采样率,以便任何应用程序(Audacity当然包括)都可以支持以任何所需的采样率播放和录制音频文件。

答案1

dmix//插件dshare总是dsnoop使用固定的采样率。

要允许设备本身以不同的速率运行,请改用 PulseAudio。

要在应用程序的数据进入dshare插件之前重新采样数据,请plug在其周围封装一个插件:

pcm.outch1 {
    type plug
    slave.pcm {
        type dshare
        ipc_key 1111
        slave usb_1
        bindings [ 0 ]
    }
}

相关内容