8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
From adafruit/Adafruit_CircuitPython_CircuitPlayground#40
@caternuson says:
Agree, I think it's going to be something lower level than CPX. I can recreate with this: import array import math import time import board import digitalio import audioio speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) # Generator thing def sine_sample(length): tone_volume = (2 ** 15) - 1 shift = 2 ** 15 for i in range(length): yield int(tone_volume * math.sin(2*math.pi*(i / length)) + shift) # Generate the sample length = 100 sine_wave = array.array("H", sine_sample(length)) sample = audioio.AudioOut(board.SPEAKER) sine_wave_sample = audioio.RawSample(sine_wave) # Play tone frequency = 330 sample_rate = int(len(sine_wave) * frequency) speaker_enable = True sine_wave_sample.sample_rate = sample_rate sample.play(sine_wave_sample, loop=True) time.sleep(1) sample.stop() sample.deinit() speaker_enable = False
Agree, I think it's going to be something lower level than CPX. I can recreate with this:
import array import math import time import board import digitalio import audioio speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) # Generator thing def sine_sample(length): tone_volume = (2 ** 15) - 1 shift = 2 ** 15 for i in range(length): yield int(tone_volume * math.sin(2*math.pi*(i / length)) + shift) # Generate the sample length = 100 sine_wave = array.array("H", sine_sample(length)) sample = audioio.AudioOut(board.SPEAKER) sine_wave_sample = audioio.RawSample(sine_wave) # Play tone frequency = 330 sample_rate = int(len(sine_wave) * frequency) speaker_enable = True sine_wave_sample.sample_rate = sample_rate sample.play(sine_wave_sample, loop=True) time.sleep(1) sample.stop() sample.deinit() speaker_enable = False
The text was updated successfully, but these errors were encountered:
655f223
No branches or pull requests
From adafruit/Adafruit_CircuitPython_CircuitPlayground#40
@caternuson says:
The text was updated successfully, but these errors were encountered: