alsa音频驱动科普第一课
做linux音频编程对alsa应该不陌生。
但是对于刚接触这块技术的同学来说是一件困难的事情。原因在于:网上关于alsa的资料太少了,特别国内的资料更是大部分重复。对于初学者来说特别苦恼。
由于笔者经历过一步步摸索的痛苦过程,现在回想起来有些问题当初可以避免的。因此把问题解决方法和经验教训写出来,引以为戒。
写一系列的技术贴与网友们分享。
录音
arecord -D hw:2,0 -f S16_LE -r 44100 -c 2 /root/record.wav
查看音频设备命令
arecord:加-l参数列出当前数字音频设备,加-L列出当前PCM设备。
arecord -D 设备名 xxx.wav可录音。
alsaconf用来配置声卡的
alsamixer用来设置声音
aplay播放wav
Example:
aplay -c 1 -t raw -r 22050 -f mu_law foobar
will play the raw file "foobar" as a 22050-Hz, mono, 8-bit, Mu-Law .au file.
arecord -d 10 -f cd -t wav -D copy foobar.wav
will record foobar.wav as a 10-second, CD-quality wave file, using the PCM "copy" (which might be defined in the user's .asoundrc file as:
arecord
命令行的声音记录器和播放器的ALSA声卡驱动
[ package | 手册 1 | 用法 | 首页 ]
Usage: arecord [OPTION]... [FILE]...
-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
Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE
Some of these may not be available on selected hardware
The available format shortcuts are:
-f cd (16 bit little endian, 44100, stereo)
-f cdr (16 bit big endian, 44100, stereo)
-f dat (16 bit little endian, 48000, stereo)
原文出处:http://www.cnblogs.com/zhuojun/
扫我吧!!!
alsa音频驱动科普第一课的更多相关文章
- 嵌入式驱动开发之---Linux ALSA音频驱动(一)
本文的部分内容参考来自DroidPhone的博客(http://blog.csdn.net/droidphone/article/details/6271122),关于ALSA写得很不错的文章,只是少 ...
- 基于Linux ALSA音频驱动的wav文件解析及播放程序 2012
本设计思路:先打开一个普通wav音频文件,从定义的文件头前面的44个字节中,取出文件头的定义消息,置于一个文件头的结构体中.然后打开alsa音频驱动,从文件头结构体取出采样精度,声道数,采样频率三个重 ...
- alsa音频驱动框架
sound/core/sound.c 实现了最顶层的file_operations,它起中转作用 sound/core/control.c 实现了控制接口的file_operations sound/ ...
- 为嵌入式mplayer移植添加ALSA音频驱动(全志V3s荔枝派zero)
首先准备mplayer和alsa_lib,我的是bulidroot添加后编译自动下载的,版本分别是alsa-lib-1.1.4.1和mplayer-1.3.0. 首先编译alsa_lib: ./con ...
- Linux ALSA声卡驱动之二:声卡的创建
1. struct snd_card 1.1. snd_card是什么 snd_card可以说是整个ALSA音频驱动最顶层的一个结构,整个声卡的软件逻辑结构开始于该结构,几乎所有与声音相关的逻辑设备都 ...
- ALSA声卡驱动中的DAPM详解之五:建立widget之间的连接关系
前面我们主要着重于codec.platform.machine驱动程序中如何使用和建立dapm所需要的widget,route,这些是音频驱动开发人员必须要了解的内容,经过前几章的介绍,我们应该知道如 ...
- 【直播回顾】OpenHarmony知识赋能第四期第四课——音频驱动开发
3月31日晚上19点,知识赋能第四期直播的第四节,也是本期最后一节直播课<OpenHarmony标准系统HDF框架之音频驱动开发>,在OpenHarmony开发者成长计划社群内成功举办 ...
- Linux音频驱动-ALSA概述
概述 ALSA(Advanced Linux Sound Architecture)是linux上主流的音频结构,在没有出现ALSA架构之前,一直使用的是OSS(Open Sound System)音 ...
- 【转】Alsa音频编程【精华】
一.前序 这里了解一下各个参数的含义以及一些基本概念. 声音是连续模拟量,计算机将它离散化之后用数字表示,就有了以下几个名词术语. 样本长度(sample):样本是记录音频数据最基本的单位,计算机对每 ...
随机推荐
- 第二章——第二节 IPC机制的概述和使用
一.Serialiable与Paracle ①.作用 ②.使用 二.Binder与AIDL ①.各自的作用 三.如何使用IPC机制 举例 四.IPC机制的原理 ①.流程图 ②.自己编译自动生成 ...
- 龙邱STM32单片机用J-LINK下载无法被识别的解决方法
问题如下: 按照正常步骤使用keil5给龙邱的stm32下载程序,SWD下载方式提示no cortex-m sw device found,JTAG方式提示no cortex-m device fou ...
- 1009 Enigma
本题的重点是理解清楚题意并能代码模拟.形式是二战德国密码机,和数据结构.算法联系较少. #include <stdio.h> #include <string.h> int m ...
- MySQL--query-cache
知识准备: 1.mysql 的query-cache是什么? mysql可以把执行完成的select 语句和这个select 语句对应的结果集缓存起来:下次再用调用相同的select 语句时就直接返 ...
- 解决 setOnItemClickListener,setOnScrollListener与setOnTouchListener事件冲突问题
代码案例如下: lvXxsdMore.setOnItemClickListener(xxsdMoreListener); //对listView 注册onclick事件 lvXxsdMore.setO ...
- poj 3318 Matrix Multiplication
http://poj.org/problem?id=3318 矩阵A*矩阵B是否等于矩阵C #include <cstdio> #include <cstring> #incl ...
- Qt中调用PolarSSL库(一)
最近一直在学习SSL相关的知识,也是先了解理论相关的知识,主要是SSL相关的基本概念和连接建立过程,主要是基于PolarSSL开源库进行学习.学习完了之后就希望能给有所运用,就想用Qt写一个简单的程序 ...
- windows 基于命令行制作vhd虚拟磁盘
什么是VHD? VHD是Virtual Hard Disk的简称,就是虚拟硬盘,就是能把VHD文件直接虚拟成一个硬盘,在其中能像真实硬盘一样操作,读取.写入.创建分区.格式化.如果你用过虚拟机,就会知 ...
- oracle数据库时间转换
select * from TAB where 时间 BETWEEN to_date('2011-02-01 22:03:40','yyyy-mm-dd hh24:mi:ss') and to_dat ...
- 格而知之8:我所理解的Runtime(3)
关联对象 14.使用Category对类进行拓展的时候,只能添加方法,而不适合添加属性(可以添加属性,也可以正常使用get方法和set方法,只是不会自动生成以下划线开头命名的成员变量). 可以通过关联 ...