Skip to content

Commit 6868f2b

Browse files
committed
Set offset value to avoid pop-noise when track start/end
1 parent 1a2ea80 commit 6868f2b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/audio_buf.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313

1414
#define SIZE_OF_SAMPLES (1024) // samples for 2ch total
1515
#define SAMPLE_RATE (44100)
16-
#define DAC_ZERO_VALUE (1) // Non-zero value For prevending pop-noise when PCM5102A enters/exits Zero Data Detect
1716

1817
// Audio Double Buffer from DMA transfer
1918
int32_t audio_buf[2][SIZE_OF_SAMPLES];
2019
// Audio Buffer for File Read
2120
int16_t buf_16b[SIZE_OF_SAMPLES];
2221

22+
int32_t DAC_ZERO_VALUE = 1; // Non-zero value For prevending pop-noise when PCM5102A enters/exits Zero Data Detect
23+
2324
volatile static int count = 0;
2425

2526
FIL fil;
@@ -222,8 +223,8 @@ static int get_audio_buf(FIL *tec, int32_t *buf_32b, int32_t *trans_number)
222223
}
223224
}
224225
for (i = 0; i < number/4; i++) {
225-
buf_32b[i*2+0] = (int32_t) swap16b((int32_t) buf_16b[i*2+0] * vol_table[volume]); // L
226-
buf_32b[i*2+1] = (int32_t) swap16b((int32_t) buf_16b[i*2+1] * vol_table[volume]); // R
226+
buf_32b[i*2+0] = (int32_t) swap16b((int32_t) buf_16b[i*2+0] * vol_table[volume]) + DAC_ZERO_VALUE; // L
227+
buf_32b[i*2+1] = (int32_t) swap16b((int32_t) buf_16b[i*2+1] * vol_table[volume]) + DAC_ZERO_VALUE; // R
227228
lvl_l += ((int32_t) buf_16b[i*2+0] * buf_16b[i*2+0]) / 32768;
228229
lvl_r += ((int32_t) buf_16b[i*2+1] * buf_16b[i*2+1]) / 32768;
229230
}

0 commit comments

Comments
 (0)