{"id":15142073,"url":"https://github.com/cedargrovestudios/circuitpython_wavebuilder","last_synced_at":"2026-02-02T06:35:09.961Z","repository":{"id":213914116,"uuid":"734535563","full_name":"CedarGroveStudios/CircuitPython_WaveBuilder","owner":"CedarGroveStudios","description":"A CircuitPython class to construct a composite synthio wave table from a collection of oscillators.","archived":false,"fork":false,"pushed_at":"2024-10-08T17:31:12.000Z","size":1027,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T00:24:57.870Z","etag":null,"topics":["arbitrary-waveform-generator","circuitpython","circuitpython-community-bundle","synthio","wave-table","waveform-generator","waveform-synthesiser"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CedarGroveStudios.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-22T00:02:37.000Z","updated_at":"2024-11-21T15:44:18.000Z","dependencies_parsed_at":"2023-12-24T09:21:44.620Z","dependency_job_id":"461ebb82-b9f8-4bd1-806d-d27d46c3c072","html_url":"https://github.com/CedarGroveStudios/CircuitPython_WaveBuilder","commit_stats":{"total_commits":30,"total_committers":1,"mean_commits":30.0,"dds":0.0,"last_synced_commit":"944e22cd4d49af7baf762eafe3e817fe27642a89"},"previous_names":["cedargrovestudios/circuitpython_wavebuilder"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedarGroveStudios%2FCircuitPython_WaveBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedarGroveStudios%2FCircuitPython_WaveBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedarGroveStudios%2FCircuitPython_WaveBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedarGroveStudios%2FCircuitPython_WaveBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CedarGroveStudios","download_url":"https://codeload.github.com/CedarGroveStudios/CircuitPython_WaveBuilder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249141202,"owners_count":21219446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arbitrary-waveform-generator","circuitpython","circuitpython-community-bundle","synthio","wave-table","waveform-generator","waveform-synthesiser"],"created_at":"2024-09-26T09:22:23.900Z","updated_at":"2026-02-02T06:35:09.901Z","avatar_url":"https://github.com/CedarGroveStudios.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Introduction\n------------\n\n.. image:: https://img.shields.io/discord/327254708534116352.svg\n    :target: https://adafru.it/discord\n    :alt: Discord\n\n.. image:: https://github.com/CedarGroveStudios/CircuitPython_Chime/workflows/Build%20CI/badge.svg\n    :target: https://github.com/CedarGroveStudios/CircuitPython_Chime/actions\n    :alt: Build Status\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: Code Style: Black\n\nA CircuitPython class to construct a composite ``synthio`` wave table\nfrom a collection of oscillators. The table is created from a list\nof oscillator characteristics, sample length, maximum sample\nvalue, a lambda factor, and loop smoothing parameters.\n\nDependencies\n------------\nThis class depends on:\n\n* `Adafruit CircuitPython \u003chttps://github.com/adafruit/circuitpython\u003e`_\n\nPlease ensure all dependencies are available on the CircuitPython filesystem.\nThis is easily achieved by downloading\n`the Adafruit library and driver bundle \u003chttps://circuitpython.org/libraries\u003e`_\nor individual libraries can be installed using\n`circup \u003chttps://github.com/adafruit/circup\u003e`_.\n\nInstalling to a Connected CircuitPython Device with Circup\n----------------------------------------------------------\n\nMake sure that you have ``circup`` installed in your Python environment.\nInstall it with the following command if necessary:\n\n.. code-block:: shell\n\n    pip3 install circup\n\nWith ``circup`` installed and your CircuitPython device connected use the\nfollowing command to install:\n\n.. code-block:: shell\n\n    circup install cedargrove_wavebuilder\n\nOr the following command to update an existing version:\n\n.. code-block:: shell\n\n    circup update\n\nUsage Example\n-------------\n\n.. code-block:: python\n\n    # SPDX-FileCopyrightText: Copyright (c) 2023 JG for Cedar Grove Maker Studios\n    # SPDX-License-Identifier: MIT\n\n    import time\n    import board\n    import synthio\n    import audiobusio\n    import audiomixer\n    from cedargrove_wavebuilder import WaveBuilder, WaveShape\n\n    # Define synth parameters\n    SAMPLE_RATE = 22050  # The sample rate in SPS\n    WAVE_TABLE_LENGTH = 512  # The wave table length in samples\n    SAMPLE_MAXIMUM = 32700  # The maximum value of a sample\n\n    # Define the oscillator wave shape, overtone ratio, and amplitude\n    tone = [(WaveShape.Sine, 1.0, 0.6)]\n\n    # Create the wave table and show the debug messages\n    wave = WaveBuilder(\n        oscillators=tone,\n        table_length=WAVE_TABLE_LENGTH,\n        sample_max=SAMPLE_MAXIMUM,\n        lambda_factor=1.0,\n        loop_smoothing=True,\n        debug=True,\n    )\n\n    # Define the tone's ADSR envelope parameters\n    tone_envelope = synthio.Envelope(\n        attack_time=0.02 + 0.01,\n        attack_level=1.0 * 1.0,\n        decay_time=0.0,\n        release_time=2.0,\n        sustain_level=1.0,\n    )\n\n    # Configure synthesizer for I2S output on a Feather S2\n    audio_output = audiobusio.I2SOut(\n        bit_clock=board.D12, word_select=board.D9, data=board.D6, left_justified=False\n    )\n    mixer = audiomixer.Mixer(\n        sample_rate=SAMPLE_RATE, buffer_size=4096, voice_count=1, channel_count=1\n    )\n    audio_output.play(mixer)\n    mixer.voice[0].level = 0.50\n\n    synth = synthio.Synthesizer(sample_rate=SAMPLE_RATE)\n    mixer.play(synth)\n\n    note_1 = synthio.Note(880, envelope=tone_envelope, waveform=wave.wave_table)\n\n    while True:\n        # Set the note waveform to sine and play the note\n        wave.oscillators = [(WaveShape.Sine, 1.0, 0.6)]\n        note_1.waveform = wave.wave_table\n        synth.press(note_1)\n        synth.release(note_1)\n        time.sleep(1)\n\n        # Set the note waveform to square and play the note\n        wave.oscillators = [(WaveShape.Saw, 1.0, 0.6)]\n        note_1.waveform = wave.wave_table\n        synth.press(note_1)\n        synth.release(note_1)\n        time.sleep(1)\n\nDocumentation\n-------------\nAPI documentation for this library can be found in `Cedargrove_WaveBuilder \u003chttps://github.com/CedarGroveStudios/CircuitPython_WaveBuilder/blob/main/media/pseudo_rtd_cedargrove_wavebuilder.pdf\u003e`_.\n\n.. image:: https://github.com/CedarGroveStudios/CircuitPython_WaveBuilder/blob/main/media/wavebuilder_api_page1a.png\n\n.. image:: https://github.com/CedarGroveStudios/CircuitPython_WaveBuilder/blob/main/media/wavebuilder_api_page2a.png\n\nFor additional detail about ``WaveBuilder``, see `Construct a synthio Waveform Object from a List of Oscillators \u003chttps://adafruit-playground.com/u/CGrover/pages/construct-a-synthio-waveform-object-from-a-list-of-oscillators\u003e`_\n\nAttribution: Patch Symbols from PATCH \u0026 TWEAK by Kim Bjørn and Chris Meyer, published by Bjooks, are licensed under Creative Commons CC BY-ND 4.0.\nSome Patch Symbols were modified to create the synthio symbols ``BlockInput``, ``MixerVoice``, ``Note``, ``Synthesizer``, ``sample``, and ``voice``.\n\nPlanned Updates\n---------------\n* Add wave table file saving.\n* Open external file as the fundamental wave table.\n* Include other preset wave types.\n* Add examples for filtering and applying ``synthio.Math`` to wave tables.\n\nAcknowledgements and Thanks\n---------------------------\n* Liz Clark, '`Circle of Fifths Euclidean Synth with synthio and CircuitPython`' Adafruit Learning Guide\n  for the waveform and noise examples.\n* Todd Kurt for essential ``synthio`` hints, tricks, and examples\n  (https://github.com/todbot/circuitpython-synthio-tricks).\n* Special thanks to Jeff Epler and Adafruit for the comprehensive design and implementation\n  of the CircuitPython ``synthio`` module.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedargrovestudios%2Fcircuitpython_wavebuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcedargrovestudios%2Fcircuitpython_wavebuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedargrovestudios%2Fcircuitpython_wavebuilder/lists"}