Skip to content

Commit e68b0db

Browse files
authored
Fix computation of half wavelength in I2s-library-examples.md
Dividing the sampleRate by the frequency results in the number of samples per complete wave. For example: with a sampling rate of 24 and a 4Hz frequency we have 24/4 -> 6 samples, which represent a wave peak to peak; we still need to divide by 2 to have its half.
1 parent d643606 commit e68b0db

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/tutorials/generic/I2s-library-examples/I2s-library-examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const int amplitude = 500; // amplitude of square wave
150150
151151
const int sampleRate = 8000; // sample rate in Hz
152152
153-
const int halfWavelength = (sampleRate / frequency); // half wavelength of square wave
153+
const int halfWavelength = (sampleRate / frequency) / 2; // half wavelength of square wave
154154
155155
short sample = amplitude; // current sample value
156156
int count = 0;
@@ -192,4 +192,4 @@ void loop() {
192192
193193
count++;
194194
}
195-
```
195+
```

0 commit comments

Comments
 (0)