1616void render_sample_block (short * sample_buff_ch0 , short * sample_buff_ch1 , int num_samples , unsigned int num_channels )
1717{
1818 // pointer to left / right sample position
19- char * ptr_l = (char * )sample_buff_ch0 ;
20- char * ptr_r = (char * )sample_buff_ch1 ;
19+ char * ptr_l = (char * )sample_buff_ch0 ;
20+ char * ptr_r = (char * )sample_buff_ch1 ;
2121 uint8_t stride = sizeof (short );
2222
2323 if (num_channels == 1 ) {
@@ -27,20 +27,16 @@ void render_sample_block(short *sample_buff_ch0, short *sample_buff_ch1, int num
2727 size_t bytes_written = 0 ;
2828 for (int i = 0 ; i < num_samples ; i ++ ) {
2929 /* low - high / low - high */
30- const char samp32 [4 ] = {ptr_l [0 ], ptr_l [1 ], ptr_r [0 ], ptr_r [1 ]}; // ESP32 CPU is Little Endian
30+ const char samp32 [4 ] = {ptr_l [0 ], ptr_l [1 ], ptr_r [0 ], ptr_r [1 ]}; // ESP32 CPU is little-endian
31+
3132 i2s_write (CONFIG_AUDIO_OUTPUT_I2S_NUM , (const char * )& samp32 , sizeof (samp32 ), & bytes_written , portMAX_DELAY );
3233
33- // DMA buffer full - retry
34- if (bytes_written == 0 ) {
35- i -- ;
36- } else {
37- ptr_l += stride ;
38- ptr_r += stride ;
39- }
34+ ptr_l += stride ;
35+ ptr_r += stride ;
4036 }
4137}
4238
43- /* Called by the NXP modifications of libmad. Sets the needed output sample rate. */
39+ /* frame callback for the libmad synth, set the needed output sample rate */
4440void set_dac_sample_rate (int rate )
4541{
4642 i2s_output_set_sample_rate (rate );
0 commit comments