Inter-IC Sound Bus (I2S) is a communication protocol for transferring digital audio signal. Using an I2S-based digital-to-analog convertor (DAC), you can play high-quality audio from Raspberry Pi™.
Mount a DAC HAT on your RaspberryPi.
Connect a pair of speakers or headphones to the anolog audio output of the DAC HAT.
Configure your Raspberry Pi hardware as described in Hardware Setup.
Ensure that you install the Raspbian image provided by MathWorks®.
Open an SSH command-line session as described in Open a Command-Line Session with Raspberry Pi Hardware.
In the terminal, type
sudo nano /boot/config.txt to
To enable the I2S interface in the Raspberry
Pi device tree, uncomment the line
dtparam=i2s=on in the hardware interface
section of the file.
To configure the HiFiBerry DAC, add
dtoverlay=hifiberry-dacplus in the lirc-rpi
module section of the file.
To disable the onboard ALSA audio devices for Raspberry
Pi, comment out the line
dtparam=audio=on in the enable audio
Disconnect Raspberry Pi from your computer and connect it again.
Ensure that the DAC HAT is still mounted on Raspberry Pi.
Configure your Simulink® model to run on Raspberry Pi as described in Model Configuration Simulink Support Package for Raspberry Pi Hardware.
Add an ALSA Audio Playback block to the model.
Open the ALSA Audio Playback block in your model. Specify the device number of the DAC HAT in the Device name parameter.
If you do not know the device number of DAC, use the
function as described in List Available ALSA Audio Output Devices.
The resulting structured array displays the device number of your
On the Simulink model toolbar, click the Deploy To Hardware button, . This action builds, downloads, and runs the model on the Raspberry Pi hardware. The audio starts playing.