如何输出32bit的i2s音频数据

mnjhuy86
Posts: 16
Joined: Fri Jun 05, 2020 8:10 am

如何输出32bit的i2s音频数据

Postby mnjhuy86 » Fri Jun 05, 2020 8:26 am

播放蓝牙音乐的时候,接收到音频是Receive music info from Bluetooth, sample_rates=44100, bits=16, ch=2。
但是我的功放是要使用bits=32的音频数据。如何修改?。谢谢

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

Re: 如何输出32bit的i2s音频数据

Postby jason.mao » Fri Jun 12, 2020 12:33 pm

Hi mnjhuy86,

重新一个my_i2s_write 函数调用 i2s_write_expand, 然后把my_i2s_write 用 audio_element_set_write_cb修改 i2s_stream element 的write 函数。

Code: Select all

 int my_i2s_write(audio_element_handle_t self, char *buffer, int len, TickType_t ticks_to_wait, void *context)
{
    i2s_stream_t *i2s = (i2s_stream_t *)audio_element_getdata(self);
    size_t bytes_written = 0;
    i2s_write_expand(i2s->config.i2s_port, buffer, len, 16, 32, &bytes_written, ticks_to_wait);
    return bytes_written;
}


    i2s_stream_cfg_t i2s_writer = I2S_STREAM_CFG_DEFAULT();
    i2s_writer.type = AUDIO_STREAM_WRITER;
    i2s_writer.stack_in_ext = true;
    i2s_writer.i2s_config.sample_rate = 48000;
    i2s_writer.i2s_config.mode = I2S_MODE_MASTER | I2S_MODE_TX;
    i2s_writer.i2s_config.bits_per_sample = 32; //for cupid digital loopback
    audio_element_handle_t my_i2s = i2s_stream_init(&i2s_writer);
    audio_element_set_write_cb(my_i2s, my_i2s_write, NULL);


mnjhuy86
Posts: 16
Joined: Fri Jun 05, 2020 8:10 am

Re: 如何输出32bit的i2s音频数据

Postby mnjhuy86 » Sat Jun 13, 2020 6:33 am

谢谢。

Who is online

Users browsing this forum: No registered users and 2 guests