Skip to content

express.py: adapt to 'audiocore', retaining compatibility with earlier versions #66

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

Merged
merged 1 commit into from
Aug 16, 2019
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
8 changes: 6 additions & 2 deletions adafruit_circuitplayground/express.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
import adafruit_thermistor
import analogio
import audioio
try:
import audiocore
except ImportError:
audiocore = audioio
import board
import busio
import digitalio
Expand Down Expand Up @@ -575,7 +579,7 @@ def _generate_sample(self, length=100):
self._sine_wave = array.array("H", Express._sine_sample(length))
if sys.implementation.version[0] >= 3:
self._sample = audioio.AudioOut(board.SPEAKER)
self._sine_wave_sample = audioio.RawSample(self._sine_wave)
self._sine_wave_sample = audiocore.RawSample(self._sine_wave)
else:
raise NotImplementedError("Please use CircuitPython 3.0 or higher.")

Expand Down Expand Up @@ -683,7 +687,7 @@ def play_file(self, file_name):
self._speaker_enable.value = True
if sys.implementation.version[0] >= 3:
with audioio.AudioOut(board.SPEAKER) as audio:
wavefile = audioio.WaveFile(open(file_name, "rb"))
wavefile = audiocore.WaveFile(open(file_name, "rb"))
audio.play(wavefile)
while audio.playing:
pass
Expand Down