Skip to main content

Quick start

Hardware and software configuration

Set the DIP switch of the RDK Audio Kit as follows (101X). In this state, the mode is set to I2S, the number of I2S channels is 1, and the I2S reference level is 3V3.

DIP switch 101X

Make sure the system image version is RDK OS 3.5.0, then download the following patch packages to the RDK X5 board.

On the board, run sudo dpkg -i hobot-* to install them.

Installing the hobot patch packages

Run srpi-config, then click 3 Interface Options > I5 Audio > Audio Driver HAT V2 in order, press Enter, and then select <Finish>. Restart as prompted, or run sudo reboot yourself to apply all the configuration.

Configuring Audio Driver HAT V2 in srpi-config

If the RDK Audio Kit is correctly installed as described above, after the reboot completes, run cat /proc/asound/cards to list all sound cards detected by ALSA. duplexaudio is the on-board sound card of the RDK X5, and duplexaudioi2s1 is the sound card of the RDK Audio Kit, which means the configuration is effective.

RDK X5 ALSA sound card information

Run ls -l /dev/snd to list the recording and playback nodes. pcmC0D0p is the playback node of PCM channel 0 device 0, and pcmC0D1c is the recording node of PCM channel 0 device 1, and so on. These two nodes correspond to the RDK Audio Kit on the RDK X5.

RDK X5 /dev/snd nodes

Feature walkthrough

This section uses the RDK X5 + RDK Audio Kit as an example to demonstrate how to record multi-channel audio with the arecord tool, play back multi-channel audio with the aplay tool, and perform full-duplex recording and playback.

Record multi-channel audio

Make sure the recording node exists. You can use the arecord command to record audio. A brief description of the arecord recording usage:

arecord [options] [output file path]
-D path:CARD,DEVICE path can be hw (direct to hardware), plughw (automatic format conversion), or default (default value)
-d recording duration
-f sample format options: S16_LE, S24_LE, S32_LE, etc.
-r sample rate common values: 8000/16000/22050/44100/48000/96000, etc.
-c channel count

Here we do not perform format conversion. Assume the sound card channel number shown by ls -l /dev/snd is 0 and the recording device number is 1. Use the S16_LE format, a sample rate of 16000, and record 8-channel audio for 10 seconds:

arecord -D hw:0,1 -d 10 -r 16000 -f S16_LE -c 8 record.wav
arecord 8-channel recording

Note that regardless of whether you use a 4-Mic or 6-Mic array, you must record 8 channels of audio. Among the 8 channels, the first 4/6 channels are the microphones of the mic array, and channels 7 and 8 are the loopback data of the stereo amplifier. When recording with 4 channels, channels 5 and 6 are empty and contain only white noise.

Play stereo audio

Make sure the playback node exists. You can use the aplay command to play audio. A brief description of the aplay playback usage:

aplay [options] [input file path]
-D path:CARD,DEVICE path can be hw (direct to hardware), plughw (automatic format conversion), or default (default value)
-d playback duration (seconds)
-f sample format options: S16_LE, S24_LE, S32_LE, etc.
-r sample rate common values: 8000/16000/22050/44100/48000/96000, etc.
-c channel count

Assume the sound card channel number shown by ls -l /dev/snd is 0 and the playback device number is 0, and play the audio file:

aplay -D hw:0,0 record.wav

The amplifier of the RDK Audio Kit is stereo. When playing multi-channel audio, the aplay tool only plays the first 2 channels.

If the sound is too low, use the following commands to adjust the DAC amplifier volume of the RDK Audio Kit. A volume of 75% is recommended for testing.

amixer -c 0 sset DAC 10%+    # turn up
amixer -c 0 sset DAC 10%- # turn down
amixer -c 0 sget DAC # view the current value
amixer -c 0 sset DAC 80% # set the percentage

Record and play back in full-duplex mode

The recording and playback nodes of the RDK Audio Kit are independent channels, supporting full-duplex recording and playback.

Open two terminals. In the first terminal, play a long audio file:

aplay -D hw:0,0 demo.wav

Place the speaker close to the mic array, and in the second terminal enter the following command to record 5 seconds of audio:

arecord -D hw:0,1 -d 5 -r 16000 -f S16_LE -c 8 record.wav

If you can hear the played audio content in the recorded audio, full-duplex recording and playback is working.

In addition, you can write a program that uses the recording and playback devices simultaneously in two threads or two processes, which also achieves full-duplex recording and playback.

Note that when DIP switch 2 is set to off, a single I2S channel is used for full-duplex recording and playback. Currently the RDK X5 and RDK S100/S100P only support this mode. For the RDK S600, you can set DIP switch 2 to on to use two independent I2S channels for recording and playback separately.

When the number of I2S channels is 1, the sample rate and sample format of playback and recording must be the same, because the recording and playback data channels share the same bit clock.

Next steps

At this point, you have experienced the basic functions of the RDK Audio Kit.

Next:

  • Mounting instructions describes the structural parameters and installation precautions of the RDK Audio Kit in detail; recommended for structural developers.
  • Hardware interface description describes the hardware interfaces of the RDK Audio Kit in detail; recommended for hardware developers.
  • To develop audio applications using this product with an RDK development board, see the USB Audio Device Usage Guide.
  • To use audio preprocessing, DOA, VAD, wake word, custom command words, ASR, TTS, and other algorithms based on the RDK Audio Kit, see the Smart Voice Box.