61.2. SMIX_DAO
61.2.1. Overview
This example demonstrates the functionality of using SMIX (Sound Mixer) audio mixer with DAO (Digital Audio Output) for audio playback and volume control. SMIX can perform sample rate conversion and mixing processing on audio with different sample rates, then output differential PWM signals through DAO to drive CLASSD amplifier chips. This example supports pause and resume functionality through GPIO button control, as well as switching SMIX mixer gain through button control.
61.2.2. Workflow
Configure system audio clock (MCLK) according to the target sample rate
Initialize I2S peripheral and DAO peripheral:
Configure I2S peripheral, including audio data format (bit width, channels, sample rate)
Enable I2S DMA transmit request
Configure DAO peripheral
Configure GPIO button interrupt for controlling audio playback pause, resume and gain switching:
Set button interrupt trigger condition
Configure button debounce handling
Enable GPIO interrupt (KEY1 for pause/resume, KEY2 for gain switching)
Configure SMIX audio mixer:
Configure source channel DMA to transfer audio data from memory to SMIX source channel
Configure destination channel DMA to transfer SMIX processed data to I2S transmit FIFO
Configure burst transfer mode (mono: DMA_NUM_TRANSFER_PER_BURST_1T; stereo: DMA_NUM_TRANSFER_PER_BURST_2T)
Set sample rate conversion parameters (support 1x, 2x, 3x, 4x, 6x, 8x, 12x ratios)
Configure mixer gain and channel mask
Enable corresponding channels
Start I2S peripheral and DAO peripheral:
Software reset I2S peripheral and DAO peripheral
Start I2S peripheral and DAO peripheral
SMIX automatically performs sample rate conversion and mixing processing
SMIX DMA transfers processed audio data to I2S TX FIFO, DAO converts I2S data and outputs
SMIX DMA completion stops I2S peripheral, DAO peripheral and SMIX channels
Support pause/resume playback through KEY1 button
Support switching SMIX mixer gain through KEY2 button
61.2.3. Audio Configuration
Audio format configuration
Support multiple input sample rates (8kHz, 16kHz, etc.)
Support 16-bit and 32-bit audio depth
Support mono (requires HPM_IP_FEATURE_DAO_AUDIO_MONO_FIX) and stereo modes
Select audio data source based on compile options:
Mono mode:
audio_mono.hStereo mode:
audio_stereo.h
SMIX configuration
Support multiple sample rate conversion ratios: 1x, 2x, 3x, 4x, 6x, 8x, 12x
Support multiple gain adjustments: -12dB, -6dB, 0dB, +6dB
Channel configuration
channel_slot_mask values - Left channel: 0x1 - Right channel: 0x2 - Stereo: 0x3
DAO channel parameter must be configured as dual-channel (channel_slot_mask = 0x3)
To play a mono audio source with DAO, configure I2S channel_slot_mask (requires HPM_IP_FEATURE_DAO_AUDIO_MONO_FIX):
0x1 plays on DAO left channel; 0x2 plays on DAO right channel
If HPM_IP_FEATURE_DAO_AUDIO_MONO_FIX is not supported, duplicate mono data to stereo and play as stereo
To play a stereo audio source with DAO, set I2S channel_slot_mask = 0x3 so both left and right output
61.2.4. Hardware Settings
Connect a speaker to the development board’s DAO interface for audio playback
Use the development board’s buttons button interface for controlling playback:
KEY1: Control playback pause/resume
KEY2: Switch SMIX mixer gain(-12dB - 0dB), the initial gain is -12dB
61.2.5. Known Issues
Some audio may produce noise when played through DAO
On-board buttons may trigger multiple GPIO interrupts due to mechanical bounce
61.2.6. Running the Example
When the project runs correctly, you should observe:
Terminal output:
Sound mixer change DAO volume example Press Key1 will pause/resume audio play, Press Key2 will change audio play gain. -- Select audio play action -- 1 - audio play
After selecting option 1:
Terminal displays “mixer play one sound”
Shows input and output sample rate information
Audio device starts playing sample audio(The initial gain is -12dB)
Button control during playback:
Press KEY1 button to pause playback, press KEY1 again to resume
Press KEY2 button to switch SMIX mixer gain between -12dB and 0dB
Terminal will display corresponding control information:
“dao_i2s pause” - pause playback
“dao_i2s resume” - resume playback
“set SMIX gain to 0dB” - set gain to 0dB
“set SMIX gain to -12dB” - set gain to -12dB