Skip to content

MP3_Decoder (AUD-6423) #1463

Closed
Closed
@LYL114

Description

@LYL114

Is your feature request related to a problem? Please describe.

如何设置mp3解码数据,指定采样率为24000

Describe the solution you'd like

通过配置,设置采样率。还是需要引入其他库将44100采样率数据转换为24000.
想要输出24000采样率,单声道数据

Additional context

// 配置并初始化MP3解码器
mp3_decoder_cfg_t mp3_cfg = DEFAULT_MP3_DECODER_CONFIG();
mp3_decoder = mp3_decoder_init(&mp3_cfg);
if (!mp3_decoder) {
    ESP_LOGE(TAG, "Failed to initialize mp3 decoder");
    cleanup();
    return ESP_FAIL;
}

audio_pipeline_register(pipeline, http_stream_reader, "http");    // 注册元素到管道
audio_pipeline_register(pipeline, mp3_decoder, "mp3");
const char* link_tags[2] = {"http", "mp3"};    // 连接元素
audio_pipeline_link(pipeline, &link_tags[0], 2);
esp_err_t err = audio_element_set_uri(http_stream_reader, url.c_str());    // 设置数据源
if (err != ESP_OK) {
    ESP_LOGE(TAG, "Failed to set URI: %s", url.c_str());
    cleanup();
    return err;
}

// 设置自定义数据接收器
audio_element_set_write_cb(mp3_decoder, pcm_data_receiver, NULL);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions