求助蓝牙播放的同时保存wav文件到sd卡失败

hector
Posts: 1
Joined: Mon Jul 22, 2019 2:35 pm

求助蓝牙播放的同时保存wav文件到sd卡失败

Postby hector » Mon Jul 22, 2019 2:50 pm

git上拉取的master分支最新代码。
examples\player\pipeline_bt_sink例程可以正常工作,手机连接蓝牙可以放歌。但是偶尔丢包,不过声音是正常的。

Code: Select all

BT_APPL: Pkt dropped
参考examples\advanced_examples\record_while_play例子,在蓝牙例程中新建了一条录音的pipeline,跑起来看日志初始化正常,但是连接蓝牙放歌的时候会不停丢包,也没有声音了,保存的wav文件也是坏的。
录音pipeline代码如下

Code: Select all

static audio_pipeline_handle_t example_create_rec_pipeline(const char *url, int sample_rates, int channels)
{
    audio_pipeline_handle_t pipeline;
    audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
    pipeline = audio_pipeline_init(&pipeline_cfg);
    mem_assert(pipeline);

    ESP_LOGI(TAG, "[ * ] Save record data as %dHz, %dChannels wav file named [%s]", sample_rates, channels, url);
    fatfs_stream_cfg_t fatfs_write_cfg = FATFS_STREAM_CFG_DEFAULT();
    fatfs_write_cfg.type = AUDIO_STREAM_WRITER;
    fatfs_stream_writer = fatfs_stream_init(&fatfs_write_cfg);

    i2s_stream_cfg_t i2s_file_cfg = I2S_STREAM_CFG_DEFAULT();
    i2s_file_cfg.type = AUDIO_STREAM_READER;
/*
	i2s_file_cfg.i2s_config.dma_buf_count = DMA_BUF_COUNT;
	i2s_file_cfg.i2s_config.dma_buf_len = DMA_BUF_LEN;
*/
    i2s_stream_reader = i2s_stream_init(&i2s_file_cfg);

    wav_encoder_cfg_t wav_file_cfg = DEFAULT_WAV_ENCODER_CONFIG();
    wav_encoder = wav_encoder_init(&wav_file_cfg);

	rsp_filter_cfg_t rsp_file_cfg = DEFAULT_RESAMPLE_FILTER_CONFIG();
	rsp_file_cfg.src_rate = 44100;
	rsp_file_cfg.src_ch = 1;
	rsp_file_cfg.dest_rate = sample_rates;
	rsp_file_cfg.dest_ch = channels;
	rsp_file_cfg.mode = RESAMPLE_DECODE_MODE;
	resample_for_rec = rsp_filter_init(&rsp_file_cfg);

    audio_pipeline_register(pipeline, i2s_stream_reader, "i2s");
    audio_pipeline_register(pipeline, wav_encoder, "wav");
	audio_pipeline_register(pipeline, resample_for_rec, "filter");
    audio_pipeline_register(pipeline, fatfs_stream_writer, "file");

	audio_pipeline_link(pipeline, (const char *[]) {"i2s", "filter", "wav", "file"}, 4);
    audio_element_set_uri(fatfs_stream_writer, url);


    return pipeline;
}

jason.mao
Posts: 98
Joined: Mon Nov 19, 2018 2:05 am

Re: 求助蓝牙播放的同时保存wav文件到sd卡失败

Postby jason.mao » Mon Oct 28, 2019 3:08 am

Hi hector,
你是需要将蓝牙的声音保存为文件吗?那可以参考这个示例,
https://github.com/espressif/esp-adf/bl ... _to_file.c

Who is online

Users browsing this forum: No registered users and 73 guests