esp32~mp3播放实例解析,Android插件化主流框架和实现原理

mp3_decoder_cfg_t mp3_cfg = DEFAULT_MP3_DECODER_CONFIG();

mp3_decoder = mp3_decoder_init(&mp3_cfg); // 初始化mp3 decoder元素

audio_element_set_read_cb(mp3_decoder, mp3_music_read_cb, NULL);

ESP_LOGI(TAG, “[2.2] Create i2s stream to write data to codec chip”);

i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT();

i2s_cfg.type = AUDIO_STREAM_WRITER;

i2s_stream_writer = i2s_stream_init(&i2s_cfg); // 初始化i2s stream元素

ESP_LOGI(TAG, “[2.3] Register all elements to audio pipeline”); // 注册元素到管道中去

audio_pipeline_register(pipeline, mp3_decoder, “mp3”);

audio_pipeline_register(pipeline, i2s_stream_writer, “i2s”);

ESP_LOGI(TAG, “[2.4] Link it together [mp3_music_read_cb]–>mp3_decoder–>i2s_stream–>[codec_chip]”);

audio_pipeline_link(pipeline, (const char *[]) {“mp3”, “i2s”}, 2); // 将mp3_music_read_cb mp3_decoder i2s_stream codec_chip关联在一起

ESP_LOGI(TAG, “[ 3 ] Initialize peripherals”);

esp_periph_config_t periph_cfg = { 0 };

esp_periph_init(&periph_cfg);

ESP_LOGI(TAG, “[3.1] Initialize Touch peripheral”);

periph_touch_cfg_t touch_cfg = {

.touch_mask = TOUCH_SEL_SET | TOUCH_SEL_PLAY | TOUCH_SEL_VOLUP | TOUCH_SEL_VOLDWN,

.tap_threshold_percent = 70,

};

esp_periph_handle_t touch_periph = periph_touch_init(&touch_cfg); // 初始化按键

ESP_LOGI(TAG, “[3.2] Start all peripherals”);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值