最近接触到amixer,大概明白了其意思和具体用法,简述如下。

alsamixer是Linux 音频架构ALSA中的Alsa工具的其中一个,用于配置音频的各个参数。

alsamixer是基于文本下的图形界面的,可以通过键盘的上下键,左右键等,很方便地设置需要的音量,开关某个switch(开关)等等操作。

amixer,是alsamixer的文本模式,即命令行模式,需要用amixer命令的形式去配置你的声卡的各个选项。

对于amixer的使用,你首先需要搞懂你要设置的参数是哪些,然后才可能去了解,如何去配置对应的值,整体来说,相对alsamixer来说,是有点繁琐,下面简要介绍其具体用法:

1.先看看amixer支持哪些命令,大概有哪些功能

# amixer
--help

Usage: amixer <options> [command]

Available options:

-h,--help       this help

-c,--card N     select the card

-D,--device N   select the device, default 'default'

-d,--debug      debug mode

-n,--nocheck    do not perform range checking

-v,--version    print version of this program

-q,--quiet      be quiet

-i,--inactive   show also inactive controls

-a,--abstract L select abstraction level (none or basic)

-s,--stdin      Read and execute commands from stdin sequentially

Available commands:

scontrols       show all mixer simple controls

scontents       show contents of all mixer simple controls (default command)

sset sID P      set contents for one mixer simple control

sget sID        get contents for one mixer simple control

controls        show all controls for given card

contents        show contents of all controls for given card

cset cID P      set control contents for one control

cget cID        get control contents for one control

2.再看看当前你的音频系统(不同的音频驱动对应不同的内容和操作接口)提供了那些供你使用的接口去操作

关于驱动里面已经提供了多少接口可以去操作,可以用命令:

amixer contents

查看,比如:

# amixer
controls

numid=3,iface=MIXER,name='Master Mode Switch'

numid=29,iface=MIXER,name='Master Mux'

numid=4,iface=MIXER,name='Master Quality Switch'

numid=2,iface=MIXER,name='Master Switch'

numid=1,iface=MIXER,name='Master Volume'

numid=7,iface=MIXER,name='PCM Mode Switch'

numid=6,iface=MIXER,name='PCM Switch'

numid=5,iface=MIXER,name='PCM Volume'

numid=21,iface=MIXER,name='Line Input Switch'

numid=16,iface=MIXER,name='Line Mode Switch'

numid=27,iface=MIXER,name='Line Mux'

。。。。。

numid=9,iface=MIXER,name='Mic Switch'

numid=8,iface=MIXER,name='Mic Volume'

numid=19,iface=MIXER,name='ADC Mode Switch'

numid=28,iface=MIXER,name='ADC Mux'

。。。。。。。。

去查看,当然你的Linux内核支持哪些配置参数,如上,一共有20多个参数可供你配置。

而对于所有的当然的配置的值,可以通过这个查看:

# amixer
contents

numid=3,iface=MIXER,name='Master Mode Switch'

; type=ENUMERATED,access=rw------,values=1,items=2

; Item #0 'Common Buffer Off'

; Item #1 'Common Buffer On'

: values=0

。。。。。。。。。。

numid=5,iface=MIXER,name='PCM Volume'

; type=INTEGER,access=rw---R--,values=2,min=0,max=27,step=0

: values=27,27

| dBscale-min=-40.50dB,step=1.50dB,mute=0

numid=24,iface=MIXER,name='Mixer ADC Mix Switch'

; type=BOOLEAN,access=rw------,values=1

: values=off

numid=26,iface=MIXER,name='Mixer DAC Mix Switch'

; type=BOOLEAN,access=rw------,values=1

: values=on

numid=25,iface=MIXER,name='Mixer Line Mix Switch'

; type=BOOLEAN,access=rw------,values=1

: values=on

numid=23,iface=MIXER,name='Mixer Mic Mix Switch'

; type=BOOLEAN,access=rw------,values=1

: values=on



3.搞懂如何去设置某个参数

总结起来就是,先要用get系列命令去看懂有哪些接口,然后再去用set系列的命令,去设置对应你所要设置的值。

想要针对某项设置,比如想要设置上面的的主音量,master volume,即controls中显示的:

numid=5,iface=MIXER,name='PCM Volume'

那么,可以先看看当前的值:

# amixer
cget numid=5,iface=MIXER,name='PCM Volume'

numid=5,iface=MIXER,name='PCM Volume'

; type=INTEGER,access=rw---R--,values=2,min=0,max=27,step=0

: values=27,27

| dBscale-min=-40.50dB,step=1.50dB,mute=0

显示的是最大的27,假设想要设置为25,那么就用cset去设置:

# amixer
cset numid=5,iface=MIXER,name='PCM Volume' 25

numid=5,iface=MIXER,name='PCM Volume'

; type=INTEGER,access=rw---R--,values=2,min=0,max=27,step=0

: values=25,25

| dBscale-min=-40.50dB,step=1.50dB,mute=0

再比如,去将'Mic Supply 的switch关闭:

# amixer
cset numid=12,iface=MIXER,name='Mic Supply Switch' Off

numid=12,iface=MIXER,name='Mic Supply Switch'

; type=ENUMERATED,access=rw------,values=1,items=2

; Item #0 'On'

; Item #1 'Off'

: values=1

总结一下用法,就是:

amixer cget    controls中所输出的某个参数

amixer cset    controls中所输出的某个参数      具体的值(比如,0,1,On,Off等)

【提示】

同上面介绍的的cget/cset系列命令:

controls        show all controls for given card

contents        show contents of all controls for given card

cset cID P      set control contents for one control

cget cID        get control contents for one control

类似的,还有另外一套sget/sset系列的命令:

scontrols       show all mixer simple controls

scontents       show contents of all mixer simple controls (default command)

sset sID P      set contents for one mixer simple control

sget sID        get contents for one mixer simple control

也是同样做法,比如:

通过查看当然有哪些选择可以控制:

# amixer
scontrols

Simple mixer control 'Master',0

Simple mixer control 'Master Mode',0

Simple mixer control 'Master Mux',0

Simple mixer control 'Master Quality',0

。。。

同理,amixer
scontents,可以查看当前所有的值,具体就不在这列举了。

另外,去查看或者配置用sget,比如:

# amixer
sget 'Microphone Input',0

Simple mixer control 'Microphone Input',0

Capabilities: pswitch pswitch-joined

Playback channels: Mono

Mono: Playback [off]

如果想要修改对应设置,用amixer sset ,具体用法是:

amixer sset sID(控制字符串) P(支持的某个值) 

其中sID,就是上面的Simple mixer control后面的那个字符串,比如'Master Mux',0

而对其设置就是,先看看其提供了哪些供你设置的值:

# amixer
sget 'Master Mux',0

Simple mixer control 'Master Mux',0

Capabilities: enum

Items: 'Sum' 'DAC' 'Line' 'Mic'

Item0: 'DAC'

然后比如要设置成Line的,就可以这样:

# amixer
sset 'Master Mux',0 Line

Simple mixer control 'Master Mux',0

Capabilities: enum

Items: 'Sum' 'DAC' 'Line' 'Mic'

Item0: 'Line'

简述amixer及其用法的更多相关文章

  1. 给iOS开发新手送点福利,简述UIDatePicker的用法

    1.Locale 设置DatePicker的地区,即设置DatePicker显示的语言. 1.跟踪所有可用的地区,取出想要的地区 NSLog(@"%@", [NSLocale av ...

  2. 简述UIDatePicker的用法

    1.Locale 设置DatePicker的地区,即设置DatePicker显示的语言. 1.跟踪所有可用的地区,取出想要的地区 NSLog(@"%@", [NSLocale av ...

  3. ALSA音频工具amixer,aplay,arecord

    ALSA音频工具编译安装 ========================================================================1.官网http://www. ...

  4. ios面试技巧

    一.软件开发流程? 软件设计思路和方法的一般过程,包括设计软件的功能和实现的算法和方法.软件的总体结构设计和模块设计.编程和调试.程序联调和测试以及编写.提交程序. 1 相关系统分析员和用户初步了解需 ...

  5. Oracle百问百答(二)

    Oracle百问百答(二) 11. nvl函数有什么用? NVL( string1, replace_with) 功能:如果string1为NULL,则NVL函数返回replace_with的值,否则 ...

  6. JS中的this的应用总结

    简述this的用法 "this是由被调用的方式确定"这个事实,使得this可以被改变,从而为函数增加了动态性,可变性,使得变成更加灵活.目前因为工作经验有限,暂时总结一下五种情况下 ...

  7. 再谈angularJS数据绑定机制及背后原理—angularJS常见问题总结

    这篇是对angularJS的一些疑点回顾,是对目前angularJS开发的各种常见问题的整理汇总.如果对文中的题目全部了然于胸,觉得对整个angular框架应该掌握的七七八八了.希望志同道合的通知补充 ...

  8. JavaSE习题 继承接口和泛型

    问答题: 1.子类在什么情况下可以继承父类友好成员? 答:在同一个包内 2.子类通过怎样的方法可以隐藏继承的成员变量? 答:声明一个与父类相同变量名的成员变量 3.子类重写继承的方法原则是什么? 答: ...

  9. angular常见问题总结

    本文引自:https://www.cnblogs.com/zhoulujun/p/8881414.html 这篇是对angularJS的一些疑点回顾,是对目前angularJS开发的各种常见问题的整理 ...

随机推荐

  1. [BZOJ5338][TJOI2018]xor

    bzoj luogu descirption 现在有一棵以 \(1\) 为根节点的由 \(n\) 个节点组成的树,树上每个节点上都有一个权值 \(v_i\) .现在有 \(Q\) 次操作,操作如下: ...

  2. LeetCode 424. Longest Repeating Character Replacement

    原题链接在这里:https://leetcode.com/problems/longest-repeating-character-replacement/description/ 题目: Given ...

  3. 【DUBBO】Dubbo原理解析-服务引用

    服务引用是服务的消费方向注册中心订阅服务提供方提供的服务地址后向服务提供方引用服务的过程. 服务的应用方在spring的配置实例如下: <dubbo:referenceid="demo ...

  4. tomcat深入学习

    总体结构:https://www.jianshu.com/p/d74eef07487f servlet相关:https://www.ibm.com/developerworks/cn/java/j-l ...

  5. bzoj 1185 [HNOI2007]最小矩形覆盖——旋转卡壳

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1185 矩形一定贴着凸包的一条边.不过只是感觉这样. 枚举一条边,对面的点就是正常的旋转卡壳. ...

  6. vue的路由初识01

    今天就做了一个vue-router的实例,(路由跳转,参数的传递[一个参数,多个参数])<!DOCTYPE html> <html> <head> <meta ...

  7. SharePoint中使用Visio Service展示业务数据

    SharePoint中可以通过Visio Service可以在浏览器中查看Visio图,功能部署到系统中,一切安好. 而现实总是很折磨人,使用该功能后,相关使用者随后提出,Visio图能否与我的业务数 ...

  8. python 函数名的应用(第一类对象),闭包,迭代器

    1.函数名的应用(第一类对象) 函数名的命名规范和变量是一样的 函数名其实就是变量名 可以作为列表中的元素进行储存. def func1(): pass def func2(): pass lst = ...

  9. MySQL 聚合函数、运算符操作、约束、表的复制

    1.聚合函数 1.分类 avg(字段名) : 求该字段平均值 sum(字段名) : 求和 max(字段名) : 最大值 min(字段名) : 最小值 count(字段名) : 统计该字段记录的个数2. ...

  10. Shiro的学习

    Apache Shiro 是 Java 的一个安全(权限)框架.它可以非常容易的开发出足够安全的应用,其不仅可以用在 JavaSE 环境,也可以用在 JavaEE 环境 . Shiro 可以完成:认证 ...