Skip to content

Commit 83e7908

Browse files
authored
Update PlayStereo.ino (#1210)
The PWMAudio lib is expecting an int16_t value but the example passes a sample cast to uint16_t So any values from the lookup table that are negative are recast to 0 i think. So half the sine wave in the case of the example is lost.
1 parent 11ac5ed commit 83e7908

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/PWMAudio/examples/PlayStereo/PlayStereo.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ void cb() {
2828
double now = ((double)cnt) / (double)freq;
2929
int fl = freqL << 7; // Prescale by 128 to avoid FP math later on
3030
int fr = freqR << 7; // Prescale by 128 to avoid FP math later on
31-
pwm.write((uint16_t)(al * sineTable[(int)(now * fl) & 127]));
32-
pwm.write((uint16_t)(ar * sineTable[(int)(now * fr) & 127]));
31+
pwm.write((int16_t)(al * sineTable[(int)(now * fl) & 127]));
32+
pwm.write((int16_t)(ar * sineTable[(int)(now * fr) & 127]));
3333
cnt++;
3434
}
3535
}

0 commit comments

Comments
 (0)