都能看懂的嵌入式linux/android alsa_aplay alsa_amixer命令行使用方法

前几天在嵌入式linux上用到alsa command,网上查的资料多不给力,仅仅有动手一点点查,最终能够用了,将这个用法告诉大家,以免大家少走弯路。

0.先查看系统支持哪几个alsa cmd:

ll /system/bin/asla*

经查,我的android4.4.2+linux3.10  的系统支持例如以下 alsa cmd

-rwxr-xr-x root     shell       68242 2014-10-08 05:18 alsa_amixer

-rwxr-xr-x root     shell       67639 2014-10-08 05:18 alsa_aplay

-rwxr-xr-x root     shell      130323 2014-10-08 05:18 alsa_ctl

不同的系统能够稍有不同,比方有的系统就叫aplay\amixer .....

1.怎样使用alsa_aplay:

alsa_aplay -h //看一下眼下支持哪些使用方法

-h, --help              help

--version           print current version

-l, --list-devices      list all soundcards and digital audio devices

-L, --list-pcms         list device names

-D, --device=NAME       select PCM by name

-q, --quiet             quiet mode

-t, --file-type TYPE    file type (voc, wav, raw or au)

-c, --channels=#        channels

-f, --format=FORMAT     sample format (case insensitive)

-r, --rate=#            sample rate

-d, --duration=#        interrupt after # seconds

-M, --mmap              mmap stream

-N, --nonblock          nonblocking mode

-F, --period-time=#     distance between interrupts is # microseconds

-B, --buffer-time=#     buffer duration is # microseconds

--period-size=#     distance between interrupts is # frames

--buffer-size=#     buffer duration is # frames

-A, --avail-min=#       min available space for wakeup is # microseconds

-R, --start-delay=#     delay for automatic PCM start is # microseconds

(relative to buffer size if <= 0)

-T, --stop-delay=#      delay for automatic PCM stop is # microseconds from xrun

-v, --verbose           show PCM structure and setup (accumulative)

-V, --vumeter=TYPE      enable VU meter (TYPE: mono or stereo)

-I, --separate-channels one file for each channel

--disable-resample  disable automatic rate resample

--disable-channels  disable automatic channel conversions

--disable-format    disable automatic format conversions

--disable-softvol   disable software volume control (softvol)

--test-position     test ring buffer position

--test-coef=#        test coeficient for ring buffer position (default 8)

expression for validation is: coef * (buffer_size / 2)

--test-nowait       do not wait for ring buffer - eats whole CPU

--max-file-time=#   start another output file when the old file has recorded

for this many seconds

--process-id-file   write the process ID here

--use-strftime      apply the strftime facility to the output file name

会有具体的help说明,这个就不说了,能够自己试。

alsa_aplay -l //列出系统有几个声卡(card 0/1/2....), 及每一个卡的一个设备(device 0/1/2....)

比方我的系统为:

**** List of PLAYBACK Hardware Devices ****

card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]

Subdevices: 8/8

Subdevice #0: subdevice #0

Subdevice #1: subdevice #1

Subdevice #2: subdevice #2

Subdevice #3: subdevice #3

Subdevice #4: subdevice #4

Subdevice #5: subdevice #5

Subdevice #6: subdevice #6

Subdevice #7: subdevice #7

card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]

Subdevices: 8/8

Subdevice #0: subdevice #0

Subdevice #1: subdevice #1

Subdevice #2: subdevice #2

Subdevice #3: subdevice #3

Subdevice #4: subdevice #4

Subdevice #5: subdevice #5

Subdevice #6: subdevice #6

Subdevice #7: subdevice #7

card 1: IntelALSASSP [IntelALSASSP], device 0: BT_DEVICE [IntelALSASSP]

Subdevices: 1/1

Subdevice #0: subdevice #0

card 1: IntelALSASSP [IntelALSASSP], device 2: BUILTIN_DEVICE [IntelALSASSP]

Subdevices: 1/1

Subdevice #0: subdevice #0

card 2: cloverviewaudio [cloverview_audio], device 0: 4 []

Subdevices: 2/2

Subdevice #0: subdevice #0

Subdevice #1: subdevice #1

card 2: cloverviewaudio [cloverview_audio], device 1: Voice rt5640-aif2-1 []

Subdevices: 1/1

Subdevice #0: subdevice #0

card 2: cloverviewaudio [cloverview_audio], device 3: BTSCO snd-soc-dummy-dai-3 []

Subdevices: 1/1

Subdevice #0: subdevice #0

card 2: cloverviewaudio [cloverview_audio], device 4: VOIP rt5640-aif2-4 []

Subdevices: 1/1

Subdevice #0: subdevice #0

card 2: cloverviewaudio [cloverview_audio], device 5: IFX_MODEM_MIXING snd-soc-dummy-dai-5 []

Subdevices: 1/1

Subdevice #0: subdevice #0

card 2: cloverviewaudio [cloverview_audio], device 6: virtual-stream rt5640-aif1-6 []

Subdevices: 1/1

Subdevice #0: subdevice #0

card 2: cloverviewaudio [cloverview_audio], device 7: CTP Probe snd-soc-dummy-dai-7 []

Subdevices: 1/1

Subdevice #0: subdevice #0

因为我的codec 为alc5640,所以

从上面得知alc5640挂在card2上,所以以后我们当配置amixer 5640时就-c 2 就对了。

2. alsa_amixer的使用方法

alsa_amixer -h //一样的help,这里不列了。

用alc5640进行mixer控制的使用方法:

# alsa_amixer -c 2 controls

例如以下:

alsa_amixer -c 2 controls

numid=35,iface=MIXER,name=‘Headphone Switch‘

numid=20,iface=MIXER,name=‘Mono ADC Capture Volume‘

numid=122,iface=MIXER,name=‘Mono ADC L1 Mux‘

numid=123,iface=MIXER,name=‘Mono ADC L2 Mux‘

numid=114,iface=MIXER,name=‘Mono ADC MIXL ADC1 Switch‘

numid=115,iface=MIXER,name=‘Mono ADC MIXL ADC2 Switch‘

numid=112,iface=MIXER,name=‘Mono ADC MIXR ADC1 Switch‘

numid=113,iface=MIXER,name=‘Mono ADC MIXR ADC2 Switch‘

numid=121,iface=MIXER,name=‘Mono ADC R1 Mux‘

numid=120,iface=MIXER,name=‘Mono ADC R2 Mux‘

numid=93,iface=MIXER,name=‘Mono DAC MIXL DAC L1 Switch‘

numid=94,iface=MIXER,name=‘Mono DAC MIXL DAC L2 Switch‘

numid=95,iface=MIXER,name=‘Mono DAC MIXL DAC R2 Switch‘

numid=92,iface=MIXER,name=‘Mono DAC MIXR DAC L2 Switch‘

numid=90,iface=MIXER,name=‘Mono DAC MIXR DAC R1 Switch‘

numid=91,iface=MIXER,name=‘Mono DAC MIXR DAC R2 Switch‘

numid=11,iface=MIXER,name=‘Mono DAC Playback Volume‘

numid=44,iface=MIXER,name=‘Mono MIX BST1 Switch‘

numid=41,iface=MIXER,name=‘Mono MIX DAC L2 Switch‘

numid=40,iface=MIXER,name=‘Mono MIX DAC R2 Switch‘

numid=43,iface=MIXER,name=‘Mono MIX OUTVOL L Switch‘

numid=42,iface=MIXER,name=‘Mono MIX OUTVOL R Switch‘

numid=85,iface=MIXER,name=‘Mono dacr Mux‘

numid=8,iface=MIXER,name=‘Mono Playback Switch‘

numid=21,iface=MIXER,name=‘ADC Boost Gain‘

numid=24,iface=MIXER,name=‘ADC IF1 Data Switch‘

numid=26,iface=MIXER,name=‘ADC IF2 Data Switch‘

numid=18,iface=MIXER,name=‘ADC Capture Switch‘

numid=19,iface=MIXER,name=‘ADC Capture Volume‘

numid=22,iface=MIXER,name=‘Class D SPK Ratio Control‘

numid=25,iface=MIXER,name=‘DAC IF1 Data Switch‘

numid=27,iface=MIXER,name=‘DAC IF2 Data Switch‘

numid=103,iface=MIXER,name=‘DAC L2 Mux‘

numid=107,iface=MIXER,name=‘DAC MIXL INF1 Switch‘

numid=106,iface=MIXER,name=‘DAC MIXL Stereo ADC Switch‘

numid=105,iface=MIXER,name=‘DAC MIXR INF1 Switch‘

numid=104,iface=MIXER,name=‘DAC MIXR Stereo ADC Switch‘

numid=102,iface=MIXER,name=‘DAC R2 Mux‘

numid=10,iface=MIXER,name=‘DAC1 Playback Volume‘

numid=9,iface=MIXER,name=‘DAC2 Playback Switch‘

numid=108,iface=MIXER,name=‘DAI select‘

numid=88,iface=MIXER,name=‘DIG MIXL DAC L1 Switch‘

numid=89,iface=MIXER,name=‘DIG MIXL DAC L2 Switch‘

numid=86,iface=MIXER,name=‘DIG MIXR DAC R1 Switch‘

numid=87,iface=MIXER,name=‘DIG MIXR DAC R2 Switch‘

numid=23,iface=MIXER,name=‘DMIC Switch‘

numid=37,iface=MIXER,name=‘Ext Spk L Switch‘

numid=38,iface=MIXER,name=‘Ext Spk R Switch‘

numid=3,iface=MIXER,name=‘HP Playback Switch‘

numid=4,iface=MIXER,name=‘HP Playback Volume‘

numid=50,iface=MIXER,name=‘HPO MIX DAC1 Switch‘

numid=49,iface=MIXER,name=‘HPO MIX DAC2 Switch‘

numid=51,iface=MIXER,name=‘HPO MIX HPVOL Switch‘

numid=36,iface=MIXER,name=‘Headset Mic Switch‘

numid=111,iface=MIXER,name=‘IF2 ADC L Mux‘

numid=110,iface=MIXER,name=‘IF2 ADC R Mux‘

numid=17,iface=MIXER,name=‘IN Capture Volume‘

numid=13,iface=MIXER,name=‘IN1 Boost‘

numid=12,iface=MIXER,name=‘IN1 Mode Control‘

numid=15,iface=MIXER,name=‘IN2 Boost‘

numid=14,iface=MIXER,name=‘IN2 Mode Control‘

numid=39,iface=MIXER,name=‘Int Mic Switch‘

numid=45,iface=MIXER,name=‘LOUT MIX DAC L1 Switch‘

numid=46,iface=MIXER,name=‘LOUT MIX DAC R1 Switch‘

numid=47,iface=MIXER,name=‘LOUT MIX OUTVOL L Switch‘

numid=48,iface=MIXER,name=‘LOUT MIX OUTVOL R Switch‘

numid=29,iface=MIXER,name=‘LPE IHF mixer‘

numid=30,iface=MIXER,name=‘LPE headset mixer‘

numid=6,iface=MIXER,name=‘OUT Channel Switch‘

numid=69,iface=MIXER,name=‘OUT MIXL BST1 Switch‘

numid=68,iface=MIXER,name=‘OUT MIXL BST3 Switch‘

numid=74,iface=MIXER,name=‘OUT MIXL DAC L1 Switch‘

numid=73,iface=MIXER,name=‘OUT MIXL DAC L2 Switch‘

numid=72,iface=MIXER,name=‘OUT MIXL DAC R2 Switch‘

numid=70,iface=MIXER,name=‘OUT MIXL INL Switch‘

numid=71,iface=MIXER,name=‘OUT MIXL REC MIXL Switch‘

numid=62,iface=MIXER,name=‘OUT MIXR BST1 Switch‘

numid=61,iface=MIXER,name=‘OUT MIXR BST2 Switch‘

numid=60,iface=MIXER,name=‘OUT MIXR BST3 Switch‘

numid=65,iface=MIXER,name=‘OUT MIXR DAC L2 Switch‘

numid=67,iface=MIXER,name=‘OUT MIXR DAC R1 Switch‘

numid=66,iface=MIXER,name=‘OUT MIXR DAC R2 Switch‘

numid=63,iface=MIXER,name=‘OUT MIXR INR Switch‘

numid=64,iface=MIXER,name=‘OUT MIXR REC MIXR Switch‘

numid=5,iface=MIXER,name=‘OUT Playback Switch‘

numid=7,iface=MIXER,name=‘OUT Playback Volume‘

numid=138,iface=MIXER,name=‘RECMIXL BST1 Switch‘

numid=137,iface=MIXER,name=‘RECMIXL BST2 Switch‘

numid=136,iface=MIXER,name=‘RECMIXL BST3 Switch‘

numid=134,iface=MIXER,name=‘RECMIXL HPOL Switch‘

numid=135,iface=MIXER,name=‘RECMIXL INL Switch‘

numid=139,iface=MIXER,name=‘RECMIXL OUT MIXL Switch‘

numid=132,iface=MIXER,name=‘RECMIXR BST1 Switch‘

numid=131,iface=MIXER,name=‘RECMIXR BST2 Switch‘

numid=130,iface=MIXER,name=‘RECMIXR BST3 Switch‘

numid=128,iface=MIXER,name=‘RECMIXR HPOR Switch‘

numid=129,iface=MIXER,name=‘RECMIXR INR Switch‘

numid=133,iface=MIXER,name=‘RECMIXR OUT MIXR Switch‘

numid=28,iface=MIXER,name=‘Register Control‘

numid=109,iface=MIXER,name=‘SDI select‘

numid=82,iface=MIXER,name=‘SPK MIXL DAC L1 Switch‘

numid=83,iface=MIXER,name=‘SPK MIXL DAC L2 Switch‘

numid=81,iface=MIXER,name=‘SPK MIXL INL Switch‘

numid=84,iface=MIXER,name=‘SPK MIXL OUT MIXL Switch‘

numid=80,iface=MIXER,name=‘SPK MIXL REC MIXL Switch‘

numid=77,iface=MIXER,name=‘SPK MIXR DAC R1 Switch‘

numid=78,iface=MIXER,name=‘SPK MIXR DAC R2 Switch‘

numid=76,iface=MIXER,name=‘SPK MIXR INR Switch‘

numid=79,iface=MIXER,name=‘SPK MIXR OUT MIXR Switch‘

numid=75,iface=MIXER,name=‘SPK MIXR REC MIXR Switch‘

numid=59,iface=MIXER,name=‘SPOL MIX BST1 Switch‘

numid=56,iface=MIXER,name=‘SPOL MIX DAC L1 Switch‘

numid=55,iface=MIXER,name=‘SPOL MIX DAC R1 Switch‘

numid=58,iface=MIXER,name=‘SPOL MIX SPKVOL L Switch‘

numid=57,iface=MIXER,name=‘SPOL MIX SPKVOL R Switch‘

numid=54,iface=MIXER,name=‘SPOR MIX BST1 Switch‘

numid=52,iface=MIXER,name=‘SPOR MIX DAC R1 Switch‘

numid=53,iface=MIXER,name=‘SPOR MIX SPKVOL R Switch‘

numid=32,iface=MIXER,name=‘SSP BT Master Mode‘

numid=34,iface=MIXER,name=‘SSP Modem Master Mode‘

numid=33,iface=MIXER,name=‘SSP VOIP Master Mode‘

numid=31,iface=MIXER,name=‘SST Probe Byte Control‘

numid=16,iface=MIXER,name=‘Speaker Boost‘

numid=1,iface=MIXER,name=‘Speaker Playback Switch‘

numid=2,iface=MIXER,name=‘Speaker Playback Volume‘

numid=125,iface=MIXER,name=‘Stereo ADC L1 Mux‘

numid=127,iface=MIXER,name=‘Stereo ADC L2 Mux‘

numid=118,iface=MIXER,name=‘Stereo ADC MIXL ADC1 Switch‘

numid=119,iface=MIXER,name=‘Stereo ADC MIXL ADC2 Switch‘

numid=116,iface=MIXER,name=‘Stereo ADC MIXR ADC1 Switch‘

numid=117,iface=MIXER,name=‘Stereo ADC MIXR ADC2 Switch‘

numid=124,iface=MIXER,name=‘Stereo ADC R1 Mux‘

numid=126,iface=MIXER,name=‘Stereo ADC R2 Mux‘

numid=101,iface=MIXER,name=‘Stereo DAC MIXL ANC Switch‘

numid=99,iface=MIXER,name=‘Stereo DAC MIXL DAC L1 Switch‘

numid=100,iface=MIXER,name=‘Stereo DAC MIXL DAC L2 Switch‘

numid=98,iface=MIXER,name=‘Stereo DAC MIXR ANC Switch‘

numid=96,iface=MIXER,name=‘Stereo DAC MIXR DAC R1 Switch‘

numid=97,iface=MIXER,name=‘Stereo DAC MIXR DAC R2 Switch‘

alsa_amixer -c 2 cget numid=2 // 从card2 获得主喇叭当时的音量

alsa_amixer -c 2 cset numid=2 39 // 从card2设置主喇叭的音量=39

alsa_amixer -c 2 cset numid=2 100% // 从card2设置主喇叭的音量=39

时间: 2024-10-10 10:16:09

都能看懂的嵌入式linux/android alsa_aplay alsa_amixer命令行使用方法的相关文章

都能看懂的嵌入式linux/android alsa_aplay alsa_amixer命令行用法

前几天在嵌入式linux上用到alsa command,网上查的资料多不给力,只有动手一点点查,终于可以用了,将这个使用方法告诉大家,以免大家少走弯路. 0.先查看系统支持哪几个alsa cmd: ll /system/bin/asla* 经查,我的android4.4.2+linux3.10  的系统支持如下 alsa cmd -rwxr-xr-x root     shell       68242 2014-10-08 05:18 alsa_amixer -rwxr-xr-x root  

嵌入式linux/android alsa_aplay alsa_amixer命令行用法

几天在嵌入式linux上用到alsa command,网上查的资料多不给力,只有动手一点点查,终于可以用了,将这个使用方法告诉大家,以免大家少走弯路. 0.先查看系统支持哪几个alsa cmd: ll /system/bin/asla* 经查,我的android4.4.2+linux3.10  的系统支持如下 alsa cmd -rwxr-xr-x root     shell       68242 2014-10-08 05:18 alsa_amixer-rwxr-xr-x root    

约瑟夫问题 算法很简单保证每隔人都能看懂用数组实现 利用循环删除数组中的元素

#include<iostream> using namespace std; const int size = 1000; void ArrDel() { int arr[size]; //循环结束标志,一直循环到数组中只剩下最后一个元素结束 int currentNum = size; int count = 0; for (int k = 0; k < size; k++) { arr[k] = k; } //currentNum==1表示数组中只剩下最后一个元素 是循环结束的标志

【视频】嵌入式Linux/Android驱动开发揭秘(1)触摸屏驱动开发

嵌入式Linux/Android驱动开发揭秘(1)触摸屏驱动开发 专题简介:自1971年,美国人SamHurst发明了世界上第一个触摸传感器以来,触摸屏技术不断革新,给了程序设计师和UI工程师无限的想象空间,它极大改善了终端用户对各种设备的操作方便程度,现在我们的日常生活如手机.平板等,已经很大程度上依赖于和习惯于使用和操作触摸屏.做为工程师,我们很有必要掌握触摸屏的工作原理和软件驱动方法,如果您对一窥如何在嵌入式中操控和使用触摸屏这一司空见惯却又神奇的技术感兴趣,敬请关注! 1.LINUX驱动

任何人都能看懂的TensorFlow介绍

本文经机器之心(微信公众号:almosthuman2014)授权转载,禁止二次转载 原文链接:任何人都能看懂的TensorFlow介绍 深度 | 机器学习敲门砖:任何人都能看懂的TensorFlow介绍 2016-08-21 机器之心 选自 kdnuggets 作者:Soon Hin Khor 机器之心编译 参与:Rick.吴攀.李亚洲 本文是日本东京 TensorFlow 聚会联合组织者 Hin Khor 所写的 TensorFlow 系列介绍文章的前两部分,自称给出了关于 TensorFlo

猴子都能看懂的Android Menu总结

简单谈谈Android menu菜单的使用,帮助入门的同学. menu主要分类: 选项菜单:最常规的菜单 子菜单:多层菜单的实现方案之一 上下文菜单:android中长按视图控件后出现的菜单 选项菜单(OptionMenu) 该菜单默认在右上角显示,有两种布局方式,xml布局和java代码布局,首先看一下在XMl中的布局方式 一个简单的代码示例 静态布局(xml): <group android:id="@+id/group1" android:checkableBehavior

【Linux工具】svn 命令行使用实例

引言 网上有这么多介绍 svn 使用的文章,为什么还要写?因为它们深入不浅出,平铺不分类,理论不实际,看完也记不住. 本文先介绍基本用法,后进行实例演练.不求大而全,只求熟练常用,自行用 svn help 举一反三(比如 -r 参数很多命令都有).如果你有环境(别忘了还有服务器),不妨花十分钟跟着实例走一遍. 简介一下 svn:一种流行的版本管理工具.基于一个 svn 服务器,开发人员用各自的电脑安装 svn 客户端后,就可以实现代码托管.版本管理.协作开发等功能.Windows 上的 svn

Unity发布Android新手教学 (小白都能看懂的教学 )

原文地址:http://blog.csdn.net/aries_h/article/details/51673338 最近在Unity的有些交流群里,发现好多Unity开发的爱好者们都遇到了这个问题. 而且都说在网上看到好多教程弄了好几天都弄不出来,每个人都解释一遍有觉得比较繁琐. 索性我就写一个博客永久保存.希望大家会喜欢. 本文纯属个人经验之谈,如有不足,欢迎指出. 下面进入正题 如果想要让Unity可以打包Apk,你需要先下载一个JDK7以上(包括7)的版本. 并且必须是64位. 安装时请

Unity 打包发布Android新手教学 (小白都能看懂的教学 ) [转]

版权声明:本文为Aries原创文章,转载请标明出处.如有不足之处欢迎提出意见或建议,联系QQ531193915 扫码关注微信公众号,获取最新资源 最近在Unity的有些交流群里,发现好多Unity开发的爱好者们都遇到了这个问题. 而且都说在网上看到好多教程弄了好几天都弄不出来,每个人都解释一遍有觉得比较繁琐. 索性我就写一个博客永久保存.希望大家会喜欢. 本文纯属个人经验之谈,如有不足,欢迎指出. 下面进入正题 如果想要让Unity可以打包Apk,你需要先下载一个JDK7以上(包括7)的版本.