Giter VIP home page Giter VIP logo

circuitpython_chime's Introduction

Introduction

Discord Build Status Code Style: Black

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 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.

Dependencies

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.

Usage Example

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)

Documentation

API documentation for this library can be found in Cedargrove_Chime_API.

https://github.com/CedarGroveStudios/CircuitPython_Chime/blob/main/media/chime_api_page3.png

Planned Updates

  • Provide additional chime scales.
  • Update the Overtones class to include aluminum, wood, and brass.
  • Add link to the 'Windless IoT Garden Chime' project.

Acknowledgements and Thanks

  • Lee Hite, 'Tubular Bell Chimes Design Handbook' for the analysis of tubular chime physics and overtones
  • C. McKenzie, T. Schweisinger, and J. Wagner, 'A Mechanical Engineering Laboratory Experiment to Investigate the Frequency Analysis of Bells and Chimes with Assessment' for the analysis of bell overtones;
  • Liz Clark, 'Circle of Fifths Euclidean Synth with synthio and CircuitPython' Adafruit Learning Guide for the waveform and noise methods;
  • Todd Kurt for fundamentally essential synthio hints, tricks, and examples (https://github.com/todbot/circuitpython-synthio-tricks).

Also, special thanks to Jeff Epler and Adafruit for the comprehensive design and implementation of the amazing CircuitPython synthio module.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.