Three-Dimensional Audio Processing with Android Device
This example shows how to use the interpolateHRTF MATLAB® function to produce a three-dimensional (3-D) audio effect on stereo audio using Simulink® Support Package for Android™ Devices. The interpolateHRFT function modifies 3-D audio by filtering it through a head-related transfer function (HRTF).
Before you start this example, we recommend that you complete the Getting Started with Android Devices.
Task 1 - Connect the Android Device
1. Connect the Android device to your computer using the USB cable.
2. Connect a pair of headphones to the headphone jack of the device.
3. Using the Hardware Setup screen, configure the Android network.
Task 2 - Open 3-D Audio with Orientation Simulink Model
Open the 3-D Audio processing with Orientation model.
The different parts of the model are described based on the functionality of the blocks used.
The input component of the model consists of the Audio Source, the Orientation block, and the Sliders to control
Audio Source reads stereo audio data using the Audio File Read block. The Orientation block reads the rotation of an Android device i.e. azimuth, roll and pitch. These three parameters are used to calculate the azimuth and elevation angles required for the
sourcePositions are constant values loaded from the
hrtfData corresponds to HRTF values measured at source positions.
sourcePositions corresponds to the source positions related to measured HRTF values.
Follow or not slider is used to select device tracking or head tracking. In device tracking, the audio direction depends only on the rotation of the Android device. In Head tracking, the audio direction depends on both the device and head direction.
Width slider is used to control the width between any two virtual loudspeakers. In this example, we consider that there are only two virtual loudspeakers.
Front Azimuth and
Front Elevation sliders are used to control the azimuth and elevation angles without using the device orientation.
Azimuth must be in the range [-180,360] and
Elevation must be in the range [-90,180].
The algorithm component of the Simulink™ model consists of two MATLAB function blocks.
Relative Azimuth/Elevation block calculates the azimuth and elevation angles based on data from the Orientation block and width, elevation, and azimuth values from the sliders.
HRTF Conversion block uses the interploateHRTF function to create a 3-D audio effect based on the azimuth and elevation values provided.
The audio output component of the model consists of the Audio Playback block, which plays the 3-D audio data on the Android device.
Task 3 - Configure the 3-D Audio with Orientation Simulink Model
1. Go to the Modeling tab and press Ctrl+E to open the Configuration Parameters dialog box.
2. In the Configuration Parameters dialog box, go to Hardware Implementation > Hardware board and select
3. Go to Hardware board settings > Target hardware resources > Groups and select Device options.
4. From the Device list, select your Android device. If your device is not listed, click Refresh.
Note: If your device is not listed even after clicking Refresh, ensure that you have enabled the USB debugging option on your device. To enable USB debugging, enter
androidhwsetup in the MATLAB® Command Window and follow the instructions.
5. Click Apply. Click OK to save your changes.
Task 4 - Configure and Run Model on Android Device
1. Open the 3-D Audio processing with Orientation model.
2. On the Hardware tab of the Simulink model, in the Mode section, select Run on board and then click Build, Deploy & Start to run this model on the Android device.
Rotate the Android device around your head with the screen always pointing to your head, the audio will appear to move in the direction the Android device is turned. Monitor the calculated azimuth and either turn or slide the azimuth slider such that you are facing close to 0 degrees to begin with.
Task 5 - Open 3-D Audio with Random Simulink Model
Similar to the 3-D Audio processing with Orientation model, you can also produce 3-D audio effect using 3-D Audio Rendering model. In this model, the azimuth angle is repetitive sequence to get the feel of 3D Audio effect.
On the Hardware tab of the Simulink model, in the Mode section, select Run on board and then click Build, Deploy & Start to run this model on the Android device.
Using the Data Input, control the elevation angle of the