A CircuitPython class for generating wind chime and bell sounds using synthio.
The CedarGrove CircuitPython Chime class provides synthio note overtones and envelopes developed from a combination of tubular chime algorithms and empirical (practical) models. Three chime voices are included in the class (Voice.Tubular
, Voice.Bell
, and Voice.Perfect
) as well as selectable chime and striker materials. The Scales
class contains a library of common wind chime and bell scales in a collection of Scientific Pitch Notation (SPN) lists.
The Chime
class is instantiated after an MCU board-specific audio output object is defined. The audio output object can be an Analog DAC or PWM GPIO pin as well as an I2S DAC output (as in the simpletest example). Chime notes are then played by the Chime.strike(root_note, amplitude)
function.
This class depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.
import time import board import random import audiobusio import audiomixer from cedargrove_chime import Chime, Scale, Voice, Material, Striker # Instantiate I2S output and mixer buffer for synthesizer audio_output = audiobusio.I2SOut( bit_clock=board.D12, word_select=board.D9, data=board.D6 ) mixer = audiomixer.Mixer( sample_rate=11020, buffer_size=4096, voice_count=1, channel_count=1 ) audio_output.play(mixer) mixer.voice[0].level = 1.0 # Instantiate the chime synth with mostly default parameters chime = Chime(mixer.voice[0], scale=Scale.HarryDavidPear) # Play scale notes sequentially for index, note in enumerate(chime.scale): chime.strike(note, 1) time.sleep(0.4) time.sleep(1) while True: # Play randomly for count in range(random.randrange(10)): chime.strike(random.choice(chime.scale), 1) time.sleep(random.randrange(1, 3) * 0.6) time.sleep(random.randrange(1, 10) * 0.5)
The Chime
class was also used for an IoT Weather Chime project using the ESB32-S2 that plays "windless" electronic chimes in accordance with the outdoor wind speed: https://github.com/CedarGroveStudios/Weather_Chimes
API documentation for this library can be found in Cedargrove_Chime_API.
Attribution: Patch Symbols from PATCH & TWEAK by Kim Bjørn and Chris Meyer, published by Bjooks, are licensed under Creative Commons CC BY-ND 4.0. Some Patch Symbols were modified to create the synthio symbols BlockInput
, MixerVoice
, Note
, Synthesizer
, sample
, and voice
.
For additional detail about synthio
diagrams, see Symbols for synthio Objects
Overtones
class to include aluminum, wood, and brass.Also, special thanks to Jeff Epler and Adafruit for the comprehensive design and implementation of the amazing CircuitPython synthio
module.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4