.. include:: ../substitutions.rst Audio ===== .. jinja:: :file: ../templates/interfaceguides/audio-intro.jinja Requirements ------------ * Headset with Microphone and CTIA Jack Development Kit Hardware Setup ------------------------------ .. jinja:: :file: ../templates/interfaceguides/audio-hw-setup.jinja 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 |ref-copy2target|. * Use the following command to download an audio file to the development kit. .. code-block:: console :substitutions: |target-prompt| wget |intf-audio-wav-http-link| * Plug a headset into the audio header (|audio-header-ref|). * Play the audio file. .. code-block:: console :substitutions: |target-prompt| aplay ImperialMarch60.wav Playing WAVE 'ImperialMarch60.wav' : |intf-audio-aplay| Recording Audio --------------- * With a headset plugged into the |audio-header-ref| audio port, run the following command to record audio and loop it back into the headset: .. warning:: In order to record audio, you need to enable the ADC by running ``amixer -c 0 cset numid=2 on``. You may also need to turn up the headphone volume by running ``alsamixer -c 0 -V all`` and increasing "HP Analog" so that you can hear the recording. .. code-block:: console :substitutions: |target-prompt| 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 .. jinja:: :file: ../templates/interfaceguides/audio-earbud-note.jinja 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. .. code-block:: console :substitutions: |target-prompt| alsamixer .. jinja:: :file: ../templates/interfaceguides/audio-alsamixer.jinja * 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. .. code-block:: console :substitutions: |target-prompt| alsactl -f board.aconf store * When you decide to reboot the development kit, run the following command to restore mixer settings. .. code-block:: console :substitutions: |target-prompt| 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). .. code-block:: console :substitutions: |target-prompt| 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 .. code-block:: console :substitutions: |target-prompt| amixer --help