Skip to content

Commit 18c9ae7

Browse files
committed
Tidy up noise examples
1 parent aa747a4 commit 18c9ae7

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

examples/noise-amps-at-freqs.py

100644100755
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
from PIL import Image, ImageDraw
33
from enviroplus.noise import Noise
44

5-
SAMPLERATE = 16000
5+
print("""noise-amps-at-freqs.py - Measure amplitude from specific frequency bins
66
7-
FREQ_LOW = 100.0
8-
FREQ_HIGH = 2000.0
9-
WIDTH = 100
7+
This example retrieves the median amplitude from 3 user-specified frequency ranges and plots them in Blue, Green and Red on the Enviro+ display.
8+
9+
As you play a continuous rising tone on your phone, you should notice peaks that correspond to the frequency entering each range.
10+
11+
Press Ctrl+C to exit!
12+
13+
""")
1014

1115
noise = Noise()
1216

@@ -25,9 +29,9 @@
2529

2630
while True:
2731
amps = noise.get_amplitudes_at_frequency_ranges([
28-
(100,200),
29-
(500,600),
30-
(1000,1200)
32+
(100, 200),
33+
(500, 600),
34+
(1000, 1200)
3135
])
3236
amps = [n * 32 for n in amps]
3337
img2 = img.copy()
@@ -38,4 +42,3 @@
3842
draw.line((0, 0, 0, amps[2]), fill=(255, 0, 0))
3943

4044
disp.display(img)
41-

examples/noise-profile.py

100644100755
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
from PIL import Image, ImageDraw
33
from enviroplus.noise import Noise
44

5-
SAMPLERATE = 16000
5+
print("""noise-profile.py - Get a simple noise profile.
66
7-
FREQ_LOW = 100.0
8-
FREQ_HIGH = 2000.0
9-
WIDTH = 100
7+
This example grabs a basic 3-bin noise profile of low, medium and high frequency noise, plotting the noise characteristics as coloured bars.
8+
9+
Press Ctrl+C to exit!
10+
11+
""")
1012

1113
noise = Noise()
1214

@@ -36,4 +38,3 @@
3638
draw.line((0, 0, 0, amp), fill=(int(low), int(mid), int(high)))
3739

3840
disp.display(img)
39-

0 commit comments

Comments
 (0)