i2s Playback Rate
Posted: Mon Jan 08, 2024 12:18 pm
Hi there;
I'm trying to achieve the effect of speeding up/slowing down audio playback based on user input. One way I can think to do this is to simply repeatedly reconfigure the i2s clock after reading some user input, before sending audio samples. But doing this inside a playback loop:
results in choppy audio, which I think implies these operations take too long to complete (?).
The other option would be investigating sample rate conversion methods, to lengthen or shorten the audio buffer I send to i2s (while keeping the i2s clock itself constant). I'm not opposed to this route, just curious why the above doesn't seem to work.
Is it unusual to try to rapidly modify the i2s clock like this? Or is it a totally reasonable approach but maybe I have some bugs elsewhere that would introduce the choppy playback?
I'm trying to achieve the effect of speeding up/slowing down audio playback based on user input. One way I can think to do this is to simply repeatedly reconfigure the i2s clock after reading some user input, before sending audio samples. But doing this inside a playback loop:
Code: Select all
i2s_channel_disable(tx_handle);
i2s_config.clk_cfg.sample_rate_hz = mp3_info.hz * USER_INPUT;
i2s_channel_reconfig_std_clock(tx_handle, &i2s_config.clk_cfg);
i2s_channel_enable(tx_handle);
The other option would be investigating sample rate conversion methods, to lengthen or shorten the audio buffer I send to i2s (while keeping the i2s clock itself constant). I'm not opposed to this route, just curious why the above doesn't seem to work.
Is it unusual to try to rapidly modify the i2s clock like this? Or is it a totally reasonable approach but maybe I have some bugs elsewhere that would introduce the choppy playback?