AUDIO Application Functions
APP_AUDIO API Brief
Application |
Brief |
|---|---|
application for audio initialization |
|
application for audio de-initialization |
|
application for audio dac open |
|
application for audio DAC close |
|
application for audio dac set volume |
|
application for check whether audio DAC for the specified source id is opened |
|
application for audio DAC get filled size of voice |
|
application for audio adc open |
|
application for audio ADC close |
|
application for reading audio ADC buffer filled size |
|
read data form ADC buffer |
|
application send audio msg to audio task |
|
start decoder to audio task |
|
get DMA count value |
|
get DMA decode information |
|
set DMA count value |
|
reopen DAC |
|
initialize audio environment settings |
|
initialize audio hardware |
|
set ANC/AEC parameter and trigger ADC to work |
|
initialize BEKEN_AUDIO service |
|
send response data by using SPP |
|
eq enable |
|
destroy audio |
APP_AUDIO API Reference
Header File
Functions
-
void app_audio_init(void)
application for audio initialization
initialize audio relevant setting, it will set audio hardware
- 返回:
N/A
-
void app_audio_deinit(void)
application for audio de-initialization
de-initialize audio relevant setting, make sure already release other audio related module before call this funcion
- 返回:
N/A
-
void app_audio_dac_open(AUDIO_SOURCE_ID id, uint32_t freq, uint32_t channels, uint32_t buff_size)
application for audio dac open
enable DAC moudle for AUDIO_SOURCE_ID
- 参数:
id – [in] audio souce ID, AUDIO_SOURCE_ID
freq – [in] audio souce sampling rate
channels – [in] audio souce channels
- 返回:
N/A
-
void app_audio_dac_close(AUDIO_SOURCE_ID id)
application for audio DAC close
diable DAC moudle for AUDIO_SOURCE_ID
- 参数:
id – [in] audio souce ID, AUDIO_SOURCE_ID
- 返回:
N/A
-
void app_audio_dac_set_volume(AUDIO_SOURCE_ID id, uint32_t volume)
application for audio dac set volume
set volume value for specific DAC source ID
- 参数:
id – [in] audio souce ID, AUDIO_SOURCE_ID
volume – [in] DAC volume index to set
- 返回:
N/A
-
uint32_t app_audio_dac_is_open(AUDIO_SOURCE_ID id)
application for check whether audio DAC for the specified source id is opened
check audio DAC for the specified source is opened or not
- 参数:
id – [in] audio souce id, AUDIO_SOURCE_ID
- 返回值:
0 – not opened
other – opened
- 返回:
result
-
uint32_t app_audio_dac_get_fill_voice_buffer_size(void)
application for audio DAC get filled size of voice
get filled size of voice DAC buffer
- 返回:
voice DAC buffer filled size
-
void app_audio_adc_open(uint32_t freq, uint32_t adc_buff_size, uint32_t enable_channel, void *p_dms_isr_cb)
application for audio adc open
set ADC relevant settings and enable it
- 参数:
freq – [in] simping rate for ADC
adc_buff_size – [in] set ADC buffer size
enable_channel – [in] ADC channel @AUDIO_ADC_CHANNEL
p_dms_isr_cb – [in] callback function for low layer
- 返回:
N/A
-
void app_audio_adc_close(void)
application for audio ADC close
close audio ADC
- 返回:
N/A
-
uint32_t app_audio_adc_get_fill_buffer_size(void)
application for reading audio ADC buffer filled size
get ADC buffer filled size
- 返回:
ADC buffer filled size
-
uint32_t app_audio_adc_read_buffer(uint8_t *buf, uint32_t len)
read data form ADC buffer
read data form ADC buffer, return value is length of data got
- 参数:
buf – [out] pointer to read buffer
len – [in] required data length
- 返回值:
0 – not data got
other – length of data got
- 返回:
data length
-
void app_audio_send_msg(audio_msg_type_t msg_type, audio_trigger_type_t trigger_type)
application send audio msg to audio task
package up audio message and send to AUDIO task
- 参数:
msg_type – [in] audio message type @audio_msg_type_t
trigger_type – [in] audio trigger type @audio_trigger_type_t
- 返回:
N/A
-
void app_audio_start_decoder(void)
start decoder to audio task
send a start decode message to AUDIO task
- 返回:
N/A
-
void app_audio_get_dma_isr_cnt(uint32_t *p_music_dma_cnt, uint32_t *p_voice_dma_cnt)
get DMA count value
get music DMA count and voice DMA count
- 参数:
p_music_dma_cnt – [out] value of music DMA count
p_voice_dma_cnt – [out] value of voice DMA count
- 返回:
N/A
-
void app_audio_get_dma_decode_info(float *p_pac_seq, uint32_t *p_frame_seq)
get DMA decode information
get sequeunce number and from DMA decode
- 参数:
p_pac_seq – [out] value of sequeunce number
p_frame_seq – [out] value of frame number
- 返回:
N/A
-
void app_audio_set_dma_isr_cnt(uint32_t p_music_dma_cnt, uint32_t p_voice_dma_cnt)
set DMA count value
update music DMA count and voice DMA count
- 参数:
p_music_dma_cnt – [in] new value for music DMA count
p_voice_dma_cnt – [in] new value for voice DMA count
- 返回:
N/A
-
void app_audio_dac_reopen(AUDIO_SOURCE_ID id)
reopen DAC
close DAC, reinitialize and update audio relevant settings, open DAC again
- 参数:
id – [in] audio source id @AUDIO_SOURCE_ID
- 返回:
N/A
-
void app_audio_env_init(void)
initialize audio environment settings
initialize audio environment relevant settings, set callback functions for DSP module. Lastly, start AUDIO task
- 返回:
N/A
-
void app_audio_hw_init(void)
initialize audio hardware
initialize audio hardware relevant settings
- 返回:
N/A
-
int32_t app_mic_ana_stable_timeout(void *pv_arg)
set ANC/AEC parameter and trigger ADC to work
callback function for timer task, it set ANC/AEC parameter and trigger to get MIC data
- 参数:
pv_arg – [in] MIC ana relevant parameters @ana_para_t
- 返回值:
0 – always 0
- 返回:
result
-
void app_audio_spp_init(void)
initialize BEKEN_AUDIO service
initialize BEKEN_AUDIO service relevant setting and hook up SPP service
- 返回:
N/A
-
void app_audio_send_spp_rsp(uint16_t length)
send response data by using SPP
end response data by using SPP after adjusting EQ settings
- 参数:
length – [in] of spp response
- 返回:
N/A
-
void app_audio_dac_eq_enable(uint32_t enable, bool dac_en)
eq enable
eq enable function
- 参数:
enable – [in]
dac – [in] enable
- 返回:
N/A
-
void app_audio_task_free(void)
destroy audio
destroy audio function
- 参数:
NA – [in]
- 返回:
N/A
Structures
-
struct audio_msg_t
AUDIO task messger struct defintion.
Public Members
-
audio_msg_type_t msg_type
message type @audio_msg_type_t
-
audio_trigger_type_t trigger_type
trigger type @audio_trigger_type_t
-
uint8_t hint_id
hints ID
-
audio_msg_type_t msg_type
-
struct aac_temp_t
AAC temp store struct definition.
-
struct ana_para_t
ANA paramreter strcut definition.
-
struct audio_spp_t
BEKEN AUDIO service struct definition.
Public Members
-
spp_server_t spp_server
SPP server information @spp_server_t
-
bool is_connected
is connected or not
-
uint16_t handle
connection handle index
-
uint8_t *p_tx_buf
data buffer which need to be sent
-
spp_server_t spp_server
-
struct plc_state_t
PLC state struct definition.
-
struct voice_info_t
voice information struct definition
Public Members
-
uint8_t recv_status
controller recive SCO data result, 0: no error
-
uint8_t rx_sco_data[120]
data buffer for recviced SCO data
-
uint8_t msbc_data[60]
data buffer for recviced mSBC data
-
uint8_t *p_tx_addr
data buffer for tx SCO data can be stored
-
uint16_t pkt_len
data length for SCO data
-
plc_state_t plc_state
PLC state @plc_state_t
-
uint32_t msbc_encode_cnt
mSBC encode count
-
uint32_t msbc_decode_cnt
mSBC decode count
-
uint32_t cvsd_encode_cnt
CVSD encode count
-
uint32_t cvsd_decode_cnt
CVSD decode count
-
uint32_t msbc_decode_error_cnt
mSBC decode error count
-
uint32_t msbc_encode_error_cnt
mSBC encode error count
-
uint32_t mic_underflow_cnt
fail to get ADC data count
-
uint32_t bt_voice_isr_cnt
system ISR count for handling BT voice data
-
bool bt_voice_triggered
boolean value for start processing BT voice data
-
uint8_t recv_status
-
struct audio_env_t
audio environment data struct definition
Public Members
-
bool audio_hw_init_done
boolean value for audio hardware module initialize done
-
bool audio_init_done
boolean value for audio initialize done
-
uint8_t audio_src_id
audio SRC ID @AUDIO_SOURCE_ID
-
uint8_t audio_chan
audio channel number
-
uint8_t audio_codec_type
audcio codec type
-
uint32_t audio_dac_music_sample_rate
dac samping rate for music
-
uint32_t audio_dac_voice_sample_rate
dac samping rate for voice
-
uint32_t audio_dac_hints_sample_rate
dac samping rate for hints
-
int32_t audio_music_volume
volume for music
-
int32_t audio_music_volume2
not used
-
int32_t audio_voice_volume
volume for voice
-
int32_t audio_voice_volume2
not used
-
int32_t audio_hints_volume
volume for hints
-
int32_t audio_hints_volume2
not used
-
uint32_t adc_dma
DMA channel value for ADC
-
uint32_t dac_music_dma
DMA channel value for music DAC
-
uint32_t dac_voice_dma
DMA channel value for voice DAC
-
uint32_t dac_hints_dma
DMA channel value for hints DAC
-
uint32_t linein_dma
DMA channel value for line in
-
ring_buffer_t audio_adc_rb
ringbuffer for ADC
-
ring_buffer_t audio_dac_music_rb
ringbuffer for music DAC
-
ring_buffer_t audio_dac_voice_rb
ringbuffer for voice DAC
-
ring_buffer_t audio_dac_hints_rb
ringbuffer for hints DAC
-
ring_buffer_node_t audio_a2dp_frame_nodes
A2DP ringbuffer node
-
ring_buffer_node_t audio_hints_frame_nodes
hints ringbuffer node
-
void *audio_a2dp_decoder_handle
address function for A2DP decoder
-
void *audio_a2dp_frame_nodes_buffer
address for A2DP data buffer
-
void *audio_hints_frame_nodes_buffer
address for hints data buffer
-
void *audio_hints_decoder_handle
address for hints decoder
-
void *audio_hfp_decoder_handle
address for voice decoder
-
void *audio_hfp_encoder_handle
address for voice encoder
-
uint32_t audio_msg_q
address for AUDIO task message queue
-
uint32_t audio_task_handle
address for AUDIO task thread
-
voice_info_t voice_info
voice information struct @voice_info_t
-
float decoding_pac_seq
decoding sequence number
-
uint32_t decoding_frame_seq
decoding frame number
-
uint32_t music_dma_isr_cnt
DMA ISR count for music
-
uint32_t voice_dma_isr_cnt
DMA ISR count for voice
-
uint32_t hints_dma_isr_cnt
DMA ISR count for hints
-
uint32_t frames_per_packet
number of Frames per A2DP media data
-
uint32_t frames_per_isr
consume frames every dma isr
-
uint16_t decode_pac_seq
pac dma isr should decode
-
uint16_t decode_frame_seq
frame dma isr should decode
-
uint32_t continuous_overflow_cnt
count for continuous fill media data failed
-
uint32_t underflow_cnt
count for get filled media data fail
-
uint32_t slow_pac_cnt
gap for the packect seq which slower than system expected
-
uint32_t slow_times_cnt
threshold value for trigger retrigger mechanism
-
uint32_t retrigger_cnt
count for retrigger times
-
uint32_t hint_used_chan_id
hints used DAC channel ID
-
uint8_t *p_music_fill_buff
buffer data for music fill data
-
uint8_t *p_hints_fill_buff
buffer data for hints fill data
-
uint32_t music_fill_size
filled data size of music
-
uint32_t hints_fill_size
filled data size of hints
-
uint32_t decoder_error_cnt
count for decoder decode error
-
aac_temp_t aac_temp
aac temp struc @aac_temp_t
-
uint16_t audio_buffer_nodes
filled node size of music buffer
-
uint32_t anc_path
ANC path index
-
bool audio_hw_init_done
Macros
-
AUDIO_SPP_PORT
-
AUDIO_SPP_MAX_TX_BUF_SIZE
-
ANA_EN_ANC
-
ANA_EN_AEC
Enumerations
-
enum audio_msg_type_t
index of ADUIO task message definition
Values:
-
enumerator AUD_MSG_START
-
enumerator AUD_MSG_RX_MEDIA_DATA
-
enumerator AUD_MSG_RX_SPEECH_DATA
-
enumerator AUD_MSG_RX_HINT_DATA
-
enumerator AUD_MSG_TX_SPEECH_DATA
-
enumerator AUD_MSG_TX_AEC_DATA
-
enumerator AUD_MSG_MUSIC_TRIGGER
-
enumerator AUD_MSG_CALL_TRIGGER
-
enumerator AUD_MSG_SHUTDOWN
-
enumerator AUD_MSG_ANC_FADE_IN
-
enumerator AUD_MSG_ANC_ON
-
enumerator AUD_MSG_ANC_TRANSPANT
-
enumerator AUD_MSG_ANC_OFF
-
enumerator AUD_MSG_PLAY_HINTS
-
enumerator AUD_MSG_END
-
enumerator AUD_MSG_START