@@ -245,12 +245,20 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self,
245
245
246
246
uint32_t max_buffer_length ;
247
247
bool single_buffer , samples_signed ;
248
- audiosample_get_buffer_structure (sample , /* single channel */ false ,
248
+ audiosample_get_buffer_structure (sample , /* single channel */ true ,
249
249
& single_buffer , & samples_signed , & max_buffer_length ,
250
250
& self -> channel_count );
251
251
self -> single_buffer = single_buffer ;
252
252
self -> samples_signed = samples_signed ;
253
253
254
+
255
+ NRF_I2S -> CONFIG .SWIDTH = self -> bytes_per_sample == 1
256
+ ? I2S_CONFIG_SWIDTH_SWIDTH_8Bit
257
+ : I2S_CONFIG_SWIDTH_SWIDTH_16Bit ;
258
+ NRF_I2S -> CONFIG .CHANNELS = self -> channel_count == 1
259
+ ? I2S_CONFIG_CHANNELS_CHANNELS_Left
260
+ : I2S_CONFIG_CHANNELS_CHANNELS_Stereo ;
261
+
254
262
choose_i2s_clocking (self , sample_rate );
255
263
/* Allocate buffers based on a maximum duration
256
264
* This duration was chosen empirically based on what would
@@ -274,9 +282,6 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self,
274
282
self -> stopping = false;
275
283
i2s_buffer_fill (self );
276
284
277
- NRF_I2S -> CONFIG .CHANNELS = self -> channel_count == 1 ? I2S_CONFIG_CHANNELS_CHANNELS_Left : I2S_CONFIG_CHANNELS_CHANNELS_Stereo ;
278
-
279
-
280
285
NRF_I2S -> RXTXD .MAXCNT = self -> buffer_length / 4 ;
281
286
NRF_I2S -> ENABLE = I2S_ENABLE_ENABLE_Enabled ;
282
287
0 commit comments