Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename _samples to _mic_samples and fix if condition #128

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
rename _samples to _mic_samples and fix if condition
  • Loading branch information
FoamyGuy committed Nov 12, 2024
commit fa981a2a56d3ef4e42609e544a8cb47b443edaf8
10 changes: 5 additions & 5 deletions adafruit_circuitplayground/bluefruit.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self) -> None:
sample_rate=16000,
bit_depth=16,
)
self._samples = None
self._mic_samples = None

@staticmethod
def _normalized_rms(values) -> float:
Expand Down Expand Up @@ -91,10 +91,10 @@ def sound_level(self) -> float:
while True:
print(cpb.sound_level)
"""
if self._sample is None:
self._samples = array.array("H", [0] * 160)
self._mic.record(self._samples, len(self._samples))
return self._normalized_rms(self._samples)
if self._mic_samples is None:
self._mic_samples = array.array("H", [0] * 160)
self._mic.record(self._mic_samples, len(self._mic_samples))
return self._normalized_rms(self._mic_samples)

def loud_sound(self, sound_threshold: int = 200) -> bool:
"""Utilise a loud sound as an input.
Expand Down