Difference between revisions of "Template:SelectAudio"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
 
(updated by API)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
===设置系统默认使用的音频设备===
+
===Set Audio Device===
如果当前系统存在多个音频设备, 例如HDMI-Audio、3.5mm耳机座、I2S-Codec时, 可以通过下列操作设置系统默认使用的音频设备。
+
If your system has multiple audio devices such as HDMI-Audio, 3.5mm audio jack and I2S-Codec you can set system's default audio device by running the following commands.
* 启动板子后,执行以下步骤安装alsa包:
+
* After your board is booted run the following commands to install alsa packages:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ apt-get update
 
$ apt-get update
Line 8: Line 8:
 
$ apt-get install alsa-utils
 
$ apt-get install alsa-utils
 
</syntaxhighlight>
 
</syntaxhighlight>
* 安装好需要的库后,查看系统当前所有的声卡设备的序列号。这里假设aplay的输出如下, 并不是真实情况, 请根据实际情况进行相对应的修改:
+
* After installation is done you can list all the audio devices by running the following command. Here is a similar list you may see after you run the command:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ aplay -l
 
$ aplay -l
Line 15: Line 15:
 
card 2: I2S codec
 
card 2: I2S codec
 
</syntaxhighlight>
 
</syntaxhighlight>
上面的信息表示card 0代表HDMI-Audio,card 1代表3.5mm耳机座, card 2代表I2S-Codec,修改配置文件/etc/asound.conf如下表示选择HDMI-Audio:  
+
"card 0" is HDMI-Audio, "card 1" is 3.5mm audio jack and "card 2" is I2S-Codec. You can set default audio device to HDMI-Audio by changing the "/etc/asound.conf" file as follows:  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
pcm.!default {
 
pcm.!default {
Line 28: Line 28:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
如果将card 0修改为card 1, 则表示选择3.5mm耳机座, 以此类推。<br>
+
If you change "card 0" to "card 1" the 3.5mm audio jack will be set to the default device.<br>
拷贝一首 .wav 格式的音乐到开发板上,播放音乐:
+
Copy a .wav file to your board and test it by running the following command:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ aplay /root/Music/test.wav
 
$ aplay /root/Music/test.wav
 
</syntaxhighlight>
 
</syntaxhighlight>
可以听见从系统默认的音频设备里输出音频。
+
You will hear sounds from system's default audio device.<br>
}}
+
If you are using H3/H5/H2+ series board with mainline kernel, the easier way is using [[npi-config]]。

Latest revision as of 01:51, 16 May 2018

Set Audio Device

If your system has multiple audio devices such as HDMI-Audio, 3.5mm audio jack and I2S-Codec you can set system's default audio device by running the following commands.

  • After your board is booted run the following commands to install alsa packages:
$ apt-get update
$ apt-get install libasound2
$ apt-get install alsa-base
$ apt-get install alsa-utils
  • After installation is done you can list all the audio devices by running the following command. Here is a similar list you may see after you run the command:
$ aplay -l
card 0: HDMI
card 1: 3.5mm codec
card 2: I2S codec

"card 0" is HDMI-Audio, "card 1" is 3.5mm audio jack and "card 2" is I2S-Codec. You can set default audio device to HDMI-Audio by changing the "/etc/asound.conf" file as follows:

pcm.!default {
    type hw
    card 0
    device 0
}
 
ctl.!default {
    type hw
    card 0
}

If you change "card 0" to "card 1" the 3.5mm audio jack will be set to the default device.
Copy a .wav file to your board and test it by running the following command:

$ aplay /root/Music/test.wav

You will hear sounds from system's default audio device.
If you are using H3/H5/H2+ series board with mainline kernel, the easier way is using npi-config