Audio
The phyCORE-AM62Ax SOM provides three Multichannel Audio Serial Ports (MCASP). The MCASP functions as a general-purpose audio serial port optimized for the needs of multichannel audio applications. This guide will show how to play and record audio with the phyCORE-AM62Ax development kit. To learn more information about the phyCORE-AM62Ax MCASP (Audio), please see section 7.7 in the Hardware Manual.
Requirements
Headset with Microphone and CTIA Jack
Development Kit Hardware Setup
The phyCORE-AM62Ax development kit can work with two different international audio jack hardware standards. The default setting is the CTIA, an audio standard used in the majority of international markets. The other headset standard is called OMTP, which is commonly used in China. The development kit is able to switch back and forth by moving two solder-on jumpers (J36, J37) to the proper configurations shown in the table below.
Mode |
J36 |
J37 |
---|---|---|
OTMP |
2+3 |
1+2 |
CTIA (Default) |
1+2 |
2+3 |
Playing an Audio File
First copy an audio file onto the development kit. This example will use the wget command, which requires a network connection. Discover more mediums that can assist in copying files by following the guide Copying Files to the Device.
Use the following command to download an audio file to the development kit.
wget https://www2.cs.uic.edu/~i101/SoundFiles/ImperialMarch60.wav
Note
You can find more audio files here.
Plug a headset into the audio header (X23).
Play the audio file.
aplay ImperialMarch60.wav
root@phyboard-lyra-am62axx-2:~# aplay ImperialMarch60.wav
Playing WAVE 'ImperialMarch60.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
Recording Audio
With a headset plugged into the X23 audio port, run the following command to record audio and loop it back into the headset:
arecord --device=sysdefault -f S16_LE -c1 -r32000 | aplay --device=sysdefault
root@phyboard-lyra-am62axx-2:~# arecord --device=sysdefault -f S16_LE -c1 -r32000 | aplay --device=sysdefault
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 32000 Hz, Mono
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 32000 Hz, Mono
Recording Audio
With a headset plugged into the X23 audio port, run the following command to record audio and loop it back into the headset:
arecord --device=sysdefault -f S16_LE -c1 -r32000 | aplay --device=sysdefault
root@phyboard-lyra-am62axx-2:~# arecord --device=sysdefault -f S16_LE -c1 -r32000 | aplay --device=sysdefault
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 32000 Hz, Mono
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 32000 Hz, Mono
Audio Mixer Settings
Control volume and various other audio setting using the ALSA soundcard driver’s ‘amixer’ or ‘alsamixer’ commands.
Changing Settings via GUI
The command ‘alsamixer’ allows the user to adjust, volume, soundcard devices and many other settings with an interactive GUI. This command is recommended for users who are note familiar with ALSA.
Use the following command to access the settings GUI.
alsamixer
Press “F6” to access the phyBOARD-Lyra sound card settings.
Change settings by utilizing your keyboard arrow keys.
Exit GUI by pressing the “esc”.
It is a good practice to save the mixer settings found to be good and reload them after every boot.
alsactl -f board.aconf store
When you decide to reboot the development kit, run the following command to restore mixer settings.
alsactl -f board.aconf restore
Changing Settings via Terminal Commands
The command ‘amixer’ allows the user to adjust, volume, soundcard devices and many other settings with terminal commands. This command is recommended for users who are familiar with ALSA.
For example, the following command sets the soundcard’s left line input volume to 80% and right line input to 40%, unmute it, and select it as a source for capture (recording).
amixer -c 0 sset Line,0 80%,40% unmute cap
To learn more about this tool use the ‘–help’ command to see the various options available
amixer --help