@@ -359,13 +359,13 @@ class I2SSource : public AudioSource {
359359
360360 memset (buffer, 0 , sizeof (float ) * num_samples); // clear output buffer
361361 I2S_datatype *newSamples = newSampleBuffer; // use global input buffer
362- I2S_datatype *newSamples4x = newSampleBuffer4x; // use oversampling global input buffer
362+ I2S_datatype *newSamples_buff = newSampleBuffer4x; // use oversampling global input buffer
363363
364364 if (num_samples > I2S_SAMPLES_MAX) num_samples = I2S_SAMPLES_MAX; // protect the buffer from overflow
365365
366366 if (_sampleRate == 96000 ) {
367367 num_samples *= 4 ;
368- err = i2s_read (I2S_NUM_0, (void *)newSamples4x , num_samples * sizeof (I2S_datatype), &bytes_read, portMAX_DELAY);
368+ err = i2s_read (I2S_NUM_0, (void *)newSamples_buff , num_samples * sizeof (I2S_datatype), &bytes_read, portMAX_DELAY);
369369 } else {
370370 err = i2s_read (I2S_NUM_0, (void *)newSamples, num_samples * sizeof (I2S_datatype), &bytes_read, portMAX_DELAY);
371371 }
@@ -382,13 +382,10 @@ class I2SSource : public AudioSource {
382382 }
383383
384384 if (_sampleRate == 96000 ) {
385- for (int i = 0 ; i < num_samples/4 ; i++) {
386- // Code for averaging. Decimation seems fine too.
387- // newSamples[i] = 0;
388- // for (int x = 0; x < 4; x++) {
389- // newSamples[i] += newSamples4x[(i*4)+x]/4;
390- // }
391- newSamples[i] = newSamples4x[(i*4 )]; // every 4th sample, skip the rest.
385+ int current = 0 ;
386+ for (int i = 0 ; i < 2048 ; i += 4 ) {
387+ newSamples[current] = newSamples_buff[i];
388+ current++;
392389 }
393390 num_samples /= 4 ; // back to 512 samples
394391 }
0 commit comments