alsa-utils移植

  1. 简介
    alsa-utils提供了一些linux下的alsa声卡测试程序,如声卡控制amixer、播放aplay和录音record,注意声音播放和录音时同一个程序,只需要将aplay名字改为arecord就是录音应用程序;
  2. 下载
    下载地址
  3. 移植
    解压后进入解压目录并运行脚本程序:
#!/bin/bash

#INSTALL_DIR=$(pwd)/_install
#cross_compiler=arm-linux-gnueabihf-
HOST=arm-linux-gnueabihf

./configure --host=${HOST} --disable-bat --disable-alsamixer
make

编译成功后在当前目录下amixer/生成amixer应用程序主要用于控制声卡操作,如设置声卡音量,数据链路等;
在aplay/目录中生成aplay应用程序,用于声音播放,注意声音播放和录音用同一个程序,只需cp aplay arecord就能得到录音程序arecord;将amixer、aplay和arecord三个应用程序拷贝到开发板上;

  1. 命令简单实用
    amixer命令:
#查看amixer帮助
amixer -h 
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
  -R,--raw-volume Use the raw value (default)
  -M,--mapped-volume Use the mapped volume

Available commands:
  scontrols       show all mixer simple controls 显示所有的mixer控件
  scontents       show contents of all mixer simple controls (default command) 显示所有的mixer控件详细信息
  sset sID P      set contents for one mixer simple control 设置 scontrols参数
  sget sID        get contents for one mixer simple control 获取 scontrols参数
  
  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 设置 controls参数
  cget cID        get control contents for one control 获取 controls参数
#注意 sset和sget是针对amixer scontrols列举的控件
#而cset和cget则是针对amixer controls列举的控件
#两者有重叠的部分,两者命令使用有一点点差别
amixer sset Headphone 90,90
amixer sget Headphone

amixer cset numid=11,iface=MIXER,name='Headphone Playback Volume'  90,90
amixer cget numid=11,iface=MIXER,name='Headphone Playback Volume'
#其中Headphone 和 numid=11,iface=MIXER,name='Headphone Playback Volume'根据
#amixer scontrols和amixer controls得到

aplay播放音频:

aplay XXX.wav

arecord录音:

#-r 采样率
#-f 格式
#-c 通道数
#-d 录音秒数
arecord -r 44100 -f S16_LE -c 2 -d 3 record.wav
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值