Skip to content

Commit 1f055b4

Browse files
committed
Merge branch 'feature/add_audio_render' into 'main'
feat(esp_audio_render): Add initial version of esp_audio_render See merge request adf/multimedia/esp-gmf!121
2 parents 25f76c1 + 7f96eab commit 1f055b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+7278
-3
lines changed

.github/workflows/upload_component.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
esp_capture: ./packages/esp_capture
2626
gmf_app_utils: ./packages/gmf_app_utils
2727
esp_board_manager: ./packages/esp_board_manager
28+
esp_audio_render: ./packages/esp_audio_render
2829
gmf_examples: ./gmf_examples
2930
namespace: "espressif"
3031
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Advanced components are encapsulation modules in ESP-GMF that target specific ap
4545
| [gmf_app_utils](./packages/gmf_app_utils) | Common peripheral configuration, unit <br>testing tools Memory leak detection tools | - `gmf_core`<br>- `protocol_examples_common`<br>- `codec_board`|
4646
| [esp_capture](./packages/esp_capture) | High-level multimedia capture module | - `gmf_core`<br>- `gmf-audio`<br>- `gmf-video`<br>- `esp_muxer`<br>- `esp_codec_dev`<br>- `esp-sr`<br>- `esp_video`<br>- `esp32-camera`|
4747
| [esp_board_manager](./packages/esp_board_manager) | Intelligent, automated board configuration and management utilities with YAML-based setup | Dependencies vary based on selected board |
48+
| [esp_audio_render](./packages/esp_audio_render) | Audio render module with mixer support | - `gmf_core`<br>- `gmf-audio`<br>|
4849

4950

5051
# ESP-GMF Usage Guide

README_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ ESP-GMF 各个模块以组件的形式存在,组件又按功能分为**原子
4545
| [gmf_app_utils](./packages/gmf_app_utils) | 常用外设配置,单元测试工具<br>内存泄漏检测工具 | - `gmf_core`<br>- `protocol_examples_common`<br>- `codec_board` |
4646
| [esp_capture](./packages/esp_capture) | 易用的音视频采集器 | - `gmf_core`<br>- `gmf-audio`<br>- `gmf-video`<br>- `esp_muxer`<br>- `esp_codec_dev`<br>- `esp-sr`<br>- `esp_video`<br>- `esp32-camera`|
4747
| [esp_board_manager](./packages/esp_board_manager) | 智能、自动化的板子配置和管理工具,支持基于 YAML 的设置 | 根据选择的板子变化依赖 |
48+
| [esp_audio_render](./packages/esp_audio_render) | 支持混音的音频渲染器 | - `gmf_core`<br>- `gmf-audio`<br>|
4849

4950
# ESP-GMF 使用说明
5051

elements/gmf_audio/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## v0.7.1
4+
5+
### Bug Fixes
6+
- Fixed sonic bypass failed for first payload
7+
8+
### Features
9+
10+
- Added audio param setting for `aud_alc`, `aud_fade`, `aud_sonic`
11+
312
## v0.7.0
413

514
### Features

elements/gmf_audio/esp_gmf_alc.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,19 @@ static esp_gmf_err_t __alc_set_gain(esp_gmf_element_handle_t handle, esp_gmf_arg
4444
uint8_t idx = (uint8_t)(*buf);
4545
alc_desc = alc_desc->next;
4646
int8_t gain = (int8_t)(*(buf + alc_desc->offset));
47-
return esp_gmf_alc_set_gain(handle, idx, gain);
47+
esp_gmf_err_t ret = ESP_GMF_ERR_OK;
48+
if (idx == 0xFF) {
49+
// Apply gain to all channels
50+
esp_ae_alc_cfg_t *config = (esp_ae_alc_cfg_t *)OBJ_GET_CFG(handle);
51+
if (config) {
52+
for (uint8_t i = 0; i < config->channel; i++) {
53+
ret |= esp_gmf_alc_set_gain(handle, i, gain);
54+
}
55+
}
56+
} else {
57+
ret = esp_gmf_alc_set_gain(handle, idx, gain);
58+
}
59+
return ret;
4860
}
4961

5062
static esp_gmf_err_t __alc_get_gain(esp_gmf_element_handle_t handle, esp_gmf_args_desc_t *arg_desc,

elements/gmf_audio/esp_gmf_audio_param.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,49 @@ esp_gmf_err_t esp_gmf_audio_param_set_dest_ch(esp_gmf_element_handle_t self, uin
5454

5555
RELEASE_AMETHOD_SETTING();
5656
}
57+
58+
esp_gmf_err_t esp_gmf_audio_param_set_speed(esp_gmf_element_handle_t self, float speed)
59+
{
60+
const char *method_name = AMETHOD(SONIC, SET_SPEED);
61+
PREPARE_AMETHOD_SETTING();
62+
63+
SET_AMETHOD_ARG(AMETHOD_ARG(SONIC, SET_SPEED, SPEED), speed);
64+
65+
RELEASE_AMETHOD_SETTING();
66+
}
67+
68+
esp_gmf_err_t esp_gmf_audio_param_set_pitch(esp_gmf_element_handle_t self, float pitch)
69+
{
70+
const char *method_name = AMETHOD(SONIC, SET_PITCH);
71+
PREPARE_AMETHOD_SETTING();
72+
73+
SET_AMETHOD_ARG(AMETHOD_ARG(SONIC, SET_PITCH, PITCH), pitch);
74+
75+
RELEASE_AMETHOD_SETTING();
76+
}
77+
78+
esp_gmf_err_t esp_gmf_audio_param_set_alc_channel_gain(esp_gmf_element_handle_t self, uint8_t ch_idx, float db)
79+
{
80+
const char *method_name = AMETHOD(ALC, SET_GAIN);
81+
// ALC currently only support int8 db
82+
int8_t gain = (int8_t) db;
83+
PREPARE_AMETHOD_SETTING();
84+
85+
SET_AMETHOD_ARG(AMETHOD_ARG(ALC, SET_GAIN, IDX), ch_idx);
86+
SET_AMETHOD_ARG(AMETHOD_ARG(ALC, SET_GAIN, GAIN), gain);
87+
88+
RELEASE_AMETHOD_SETTING();
89+
}
90+
91+
esp_gmf_err_t esp_gmf_audio_param_set_fade(esp_gmf_element_handle_t self, bool is_fade_in)
92+
{
93+
const char *method_name = AMETHOD(FADE, SET_MODE);
94+
// Aligned with ESP_AE_FADE_MODE_FADE_IN = 1, ESP_AE_FADE_MODE_FADE_OUT = 2
95+
int32_t mode = is_fade_in ? 1 : 2;
96+
97+
PREPARE_AMETHOD_SETTING();
98+
99+
SET_AMETHOD_ARG(AMETHOD_ARG(FADE, SET_MODE, MODE), mode);
100+
101+
RELEASE_AMETHOD_SETTING();
102+
}

elements/gmf_audio/esp_gmf_sonic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static esp_gmf_job_err_t esp_gmf_sonic_process(esp_gmf_element_handle_t self, vo
157157
esp_gmf_payload_t *in_load = NULL;
158158
esp_gmf_payload_t *out_load = NULL;
159159
bool is_done = false;
160+
sonic->out_data_hd.needed_num = sonic->out_size / sonic->bytes_per_sample;
160161
if (sonic->speed == 1.0f && sonic->pitch == 1.0f && (sonic->out_data_hd.out_num < sonic->out_data_hd.needed_num)) {
161162
out_len = gmf_sonic_bypass_process(sonic, in_port, out_port, &in_load, &out_load);
162163
goto __sonic_release;
@@ -188,7 +189,6 @@ static esp_gmf_job_err_t esp_gmf_sonic_process(esp_gmf_element_handle_t self, vo
188189
}
189190
load_ret = esp_gmf_port_acquire_out(out_port, &out_load, sonic->out_size, ESP_GMF_MAX_DELAY);
190191
ESP_GMF_PORT_ACQUIRE_OUT_CHECK(TAG, load_ret, out_len, goto __sonic_release);
191-
sonic->out_data_hd.needed_num = sonic->out_size / sonic->bytes_per_sample;
192192
sonic->out_data_hd.samples = out_load->buf;
193193
out_load->valid_size = 0;
194194
out_load->pts = sonic->cur_pts;

elements/gmf_audio/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "0.7.0"
1+
version: "0.7.1"
22
description: Espressif GMF Audio Elements Module
33
url: https://github.com/espressif/esp-gmf/tree/main/elements/gmf_audio
44
documentation: "https://github.com/espressif/esp-gmf/blob/main/elements/gmf_audio/README.md"

elements/gmf_audio/include/esp_gmf_audio_param.h

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,74 @@ esp_gmf_err_t esp_gmf_audio_param_set_dest_bits(esp_gmf_element_handle_t self, u
5555
*/
5656
esp_gmf_err_t esp_gmf_audio_param_set_dest_ch(esp_gmf_element_handle_t self, uint8_t dest_ch);
5757

58+
/**
59+
* @brief Set speed for audio element
60+
*
61+
* @param[in] handle Audio element handle
62+
* @param[in] speed Audio playback speed
63+
*
64+
* @return
65+
* - ESP_GMF_ERR_OK On success
66+
* - ESP_GMF_ERR_NOT_FOUND Not found the method
67+
* - ESP_GMF_ERR_MEMORY_LACK Failed to allocate memory
68+
* - Others Failed to apply method
69+
*/
70+
esp_gmf_err_t esp_gmf_audio_param_set_speed(esp_gmf_element_handle_t self, float speed);
71+
72+
/**
73+
* @brief Set pitch for audio element
74+
*
75+
* @param[in] handle Audio element handle
76+
* @param[in] pitch Audio pitch to set
77+
*
78+
* @return
79+
* - ESP_GMF_ERR_OK On success
80+
* - ESP_GMF_ERR_NOT_FOUND Not found the method
81+
* - ESP_GMF_ERR_MEMORY_LACK Failed to allocate memory
82+
* - Others Failed to apply method
83+
*/
84+
esp_gmf_err_t esp_gmf_audio_param_set_pitch(esp_gmf_element_handle_t self, float pitch);
85+
86+
/**
87+
* @brief Set ALC certain channel gain for audio element
88+
*
89+
* @param[in] handle Audio element handle
90+
* @param[in] ch_idx Channel index (0: Left channel 1: Right Channel 0xFF: All channels)
91+
* @param[in] gain_db ALC gain (unit decibel)
92+
*
93+
* @return
94+
* - ESP_GMF_ERR_OK On success
95+
* - ESP_GMF_ERR_NOT_FOUND Not found the method
96+
* - ESP_GMF_ERR_MEMORY_LACK Failed to allocate memory
97+
* - Others Failed to apply method
98+
*/
99+
esp_gmf_err_t esp_gmf_audio_param_set_alc_channel_gain(esp_gmf_element_handle_t self, uint8_t ch_idx, float gain_db);
100+
101+
/**
102+
* @brief Set ALC gain for all channels
103+
*/
104+
#define esp_gmf_audio_param_set_alc_gain(self, gain_db) esp_gmf_audio_param_set_alc_channel_gain(self, 0xFF, gain_db)
105+
106+
/**
107+
* @brief Set fade in/out direction for audio element
108+
*
109+
* @param[in] handle Audio element handle
110+
* @param[in] is_fade_in Whether fade in or out
111+
*
112+
* @return
113+
* - ESP_GMF_ERR_OK On success
114+
* - ESP_GMF_ERR_NOT_FOUND Not found the method
115+
* - ESP_GMF_ERR_MEMORY_LACK Failed to allocate memory
116+
* - Others Failed to apply method
117+
*/
118+
esp_gmf_err_t esp_gmf_audio_param_set_fade(esp_gmf_element_handle_t self, bool is_fade_in);
119+
120+
/**
121+
* @brief Helper wrapper for fade in and fade out setting
122+
*/
123+
#define esp_gmf_audio_param_set_fade_in(self) esp_gmf_audio_param_set_fade(self, true);
124+
#define esp_gmf_audio_param_set_fade_out(self) esp_gmf_audio_param_set_fade(self, false);
125+
58126
#ifdef __cplusplus
59127
}
60128
#endif
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Gather common sources
2+
set(COMPONENT_SRC_DIRS "src")
3+
4+
set(COMPONENT_INCLUDE "./include")
5+
6+
set(COMPONENT_PRIV_INCLUDE "private_inc")
7+
8+
idf_component_register(
9+
SRC_DIRS ${COMPONENT_SRC_DIRS}
10+
INCLUDE_DIRS ${COMPONENT_INCLUDE}
11+
PRIV_INCLUDE_DIRS ${COMPONENT_PRIV_INCLUDE}
12+
REQUIRES esp_timer
13+
)

0 commit comments

Comments
 (0)