X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/blobdiff_plain/aa747a416652b64a182d6e2594c08e2476d17d76..f8d88341a5c4dbc710ada549f5d7a9dc272c4040:/examples/noise-amps-at-freqs.py?ds=inline diff --git a/examples/noise-amps-at-freqs.py b/examples/noise-amps-at-freqs.py old mode 100644 new mode 100755 index 0a8040b..8b1ddd5 --- a/examples/noise-amps-at-freqs.py +++ b/examples/noise-amps-at-freqs.py @@ -2,11 +2,15 @@ import ST7735 from PIL import Image, ImageDraw from enviroplus.noise import Noise -SAMPLERATE = 16000 +print("""noise-amps-at-freqs.py - Measure amplitude from specific frequency bins -FREQ_LOW = 100.0 -FREQ_HIGH = 2000.0 -WIDTH = 100 +This example retrieves the median amplitude from 3 user-specified frequency ranges and plots them in Blue, Green and Red on the Enviro+ display. + +As you play a continuous rising tone on your phone, you should notice peaks that correspond to the frequency entering each range. + +Press Ctrl+C to exit! + +""") noise = Noise() @@ -25,9 +29,9 @@ draw = ImageDraw.Draw(img) while True: amps = noise.get_amplitudes_at_frequency_ranges([ - (100,200), - (500,600), - (1000,1200) + (100, 200), + (500, 600), + (1000, 1200) ]) amps = [n * 32 for n in amps] img2 = img.copy() @@ -38,4 +42,3 @@ while True: draw.line((0, 0, 0, amps[2]), fill=(255, 0, 0)) disp.display(img) -