如何将“Line In”麦克风从单声道更改为立体声

如何将“Line In”麦克风从单声道更改为立体声

我正在开发一个使用 alsa 线路输入和线路输出的项目,我想分离左和右线路输入/输出,以便能够有两个独立的单声道音频输入和输出。我在“asoundrc”文件中使用以下配置完成了此操作:

pcm.dsnoop0 {
    type dsnoop     # Direct snoop
    ipc_key 321400     # unique IPC key
    ipc_key_add_uid true    # add current uid to unique IPC key
    slave{
        pcm "hw:0,0"
        #format S32_LE
        rate 16000
        period_time 0
        channels 2
        period_size 320  # must be power of 2
        buffer_size 10240  # ditto
    }
    bindings{
        0 0
    }
}
pcm.dmix0 {
    type dmix
    ipc_key 321410  # any unique value
    ipc_key_add_uid true
    slave{
        pcm "hw:0,0"
        #format S16_LE
        rate 16000
        period_time 0
        channels 2
        period_size 320  # must be power of 2
        buffer_size 10240  # ditto
    }
    bindings {
        0 0
    }
}

pcm.duplex0 {
    type asym
    playback.pcm dmix0
    capture.pcm dsnoop0

}
pcm.plug0 {
    type plug
    slave.pcm "duplex0"
}

pcm.dsnoop1 {
    type dsnoop     # Direct snoop
    ipc_key 321420     # unique IPC key
    ipc_key_add_uid true    # add current uid to unique IPC key
    slave{
        pcm "hw:0,0"
        #format S32_LE
        rate 16000
        channels 2
        period_time 0
        period_size 320  # must be power of 2
        buffer_size 10240  # ditto
    }
    bindings {
        1 1
    }

}
pcm.dmix1 {
    type dmix
    ipc_key 321430  # any unique value
    ipc_key_add_uid true
    slave{
        pcm "hw:0,0"
        #format S16_LE
        rate 16000
        period_time 0
        channels 2
        period_size 320  # must be power of 2
        buffer_size 10240  # ditto
    }
    bindings{
    1 1
    }
}

pcm.duplex1 {
    type asym
    playback.pcm dmix1
    capture.pcm dsnoop1

}
pcm.plug1 {
    type plug
    slave.pcm "duplex1"
}

音频输出工作正常,但我的 ubuntu 将“线路输入”确定为单声道,我怎样才能将其更改为立体声“线路输入”?

答案1

我找到了解决方案,问题出在我的ipc_key上:

pcm.dev0{
    type hw
    card 0
    device 0

}
ctl.dev0{
    type hw
    card 0
}

pcm.dmix0 {
    type dmix
    ipc_key 321400  # any unique value
    ipc_key_add_uid 1    # add current uid to unique IPC key
    ipc_perm 0666
    slave{
        pcm dev0
        format S16_LE
        rate 16000
        period_time 0
        channels 2
        period_size 320  # must be power of 2
        buffer_size 10240  # ditto
    }
    bindings {
        0 0
    }
}
pcm.dmix1 {
    type dmix
    ipc_key 321400  # any unique value
    ipc_key_add_uid 1    # add current uid to unique IPC key
    ipc_perm 0666
    slave{
        pcm dev0
        format S16_LE
        rate 16000
        period_time 0
        channels 2
        period_size 320  # must be power of 2
        buffer_size 10240  # ditto
    }
    bindings {
        1 1
    }
}

pcm.dsnoop0 {
    type dsnoop     # Direct snoop
    ipc_key 321400     # unique IPC key
    ipc_perm 0666
    slave{
        pcm dev0
        format S16_LE
        rate 16000
        period_time 0
        channels 2
        period_size 320  # must be power of 2
        buffer_size 10240  # ditto
    }
    bindings.0 0
}

pcm.dsnoop1 {
    type dsnoop     # Direct snoop
    ipc_key 321400     # unique IPC key

    ipc_perm 0666
    slave{
        pcm dev0
        format S16_LE
        rate 16000
        period_time 0
        channels 2
        period_size 320  # must be power of 2
        buffer_size 10240  # ditto
    }
    bindings.0 1
}

pcm.duplex0 {
    type asym
    playback.pcm dmix0
    capture.pcm dsnoop0
    #bindings.0 0

}

pcm.duplex1 {
    type asym
    playback.pcm dmix1
    capture.pcm dsnoop1

}

pcm.plug0 {
    type plug
    slave.pcm "duplex0"
}

pcm.plug1 {
    type plug
    slave.pcm "duplex1"
}

相关内容