better audio with only a few glitches left

This commit is contained in:
Sebastian
2025-06-15 02:52:54 +02:00
parent 76f2e0ec28
commit ecbd6ab3ee
3 changed files with 27 additions and 13 deletions

View File

@ -18,7 +18,7 @@
#define AURAL 1
#define UI_SAMPLERATE 22050
#define BUFFERSIZE 1024
#define BUFFERSIZE 64
#define NSTREAMS 8
int16_t buffer[BUFFERSIZE];
@ -100,7 +100,7 @@ void codec_transmit() {
int16_t sample = 0;
int j = active % NSTREAMS;
sample = stream[j].get();
buffer[i] += sample;
buffer[i] = sample >> 2;
}
i2s.write((const uint8_t *)&buffer, count * sizeof(int16_t));
@ -236,12 +236,12 @@ void setup() {
i2s.setDIN(14);
i2s.setBCLK(16); // Note: LRCLK = BCLK + 1
i2s.setMCLK(18);
i2s.setMCLKmult(256); // 12.288.000Hz
i2s.setMCLKmult(512); // 256 = 12.288.000Hz 512 = 25Mhz
i2s.swapClocks();
i2s.setBitsPerSample(16);
i2s.setBuffers(4, BUFFERSIZE * sizeof(int16_t) / sizeof(uint32_t));
i2s.setBuffers(6, BUFFERSIZE * sizeof(int16_t) / sizeof(uint32_t));
if(!i2s.begin(48000)){
Serial.println("I2S error!");
@ -269,7 +269,8 @@ void setup() {
Serial.print(stream[i].wavefile.blockalign);
Serial.println(" bytes");
//stream[i].play();
stream[i].play();
stream[i].wavefile.loop = true;
} else {
Serial.println("file loading error");
}
@ -423,13 +424,24 @@ void loop() {
if(i2s.getOverflow()) Serial.println("overflow");
if(i2s.getUnderflow()) Serial.println("underflow");
delay(20); // wait 1ms
//delay(20); // wait 1ms
}
void setup1(){
// while(1){
// if(streams_loaded){
// int16_t l, r;
// i2s.read16(&l, &r);
// int j = active % NSTREAMS;
// l = stream[j].get() >> 2;
// r = stream[j].get() >> 2;
// i2s.write16(l, r);
// }
// }
}
void loop1(){
}