{"id":25762437,"url":"https://github.com/micyg/polytheremin_software","last_synced_at":"2025-06-13T20:36:50.246Z","repository":{"id":277891301,"uuid":"926229265","full_name":"MiCyg/PolyTheremin_Software","owner":"MiCyg","description":"Software implementation of PolyTheremin on rp2040","archived":false,"fork":false,"pushed_at":"2025-02-16T19:47:11.000Z","size":1148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T20:29:25.278Z","etag":null,"topics":["capacitive-touch","polytheremin","rp2040","theremin"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MiCyg.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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":"2025-02-02T21:03:21.000Z","updated_at":"2025-02-16T19:47:15.000Z","dependencies_parsed_at":"2025-02-16T20:40:32.535Z","dependency_job_id":null,"html_url":"https://github.com/MiCyg/PolyTheremin_Software","commit_stats":null,"previous_names":["micyg/polytheremin_software"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiCyg%2FPolyTheremin_Software","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiCyg%2FPolyTheremin_Software/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiCyg%2FPolyTheremin_Software/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiCyg%2FPolyTheremin_Software/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MiCyg","download_url":"https://codeload.github.com/MiCyg/PolyTheremin_Software/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240926383,"owners_count":19879738,"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":["capacitive-touch","polytheremin","rp2040","theremin"],"created_at":"2025-02-26T19:53:01.984Z","updated_at":"2025-02-26T19:53:02.569Z","avatar_url":"https://github.com/MiCyg.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PolyTheremin Software\n\n![PolyTheremin under development](doc/PolyTheremin_testPlatform.png)\n\n## Overview\n\nThis repository contains the software implementation of the [PolyTheremin project](https://github.com/MiCyg/PolyTheremin) (Currently on the development). The code has been tested on my [testing platform](https://github.com/MiCyg/PolyTheremin_Hardware), connected to four metal antennas.\nThis project implements a polyphonic theremin using the RP2040 microcontroller, utilizing FreeRTOS for real-time processing and the CMSIS-DSP library for frequency calculations and calculate decorelator in future.\n\n[![YouTube](http://i.ytimg.com/vi/87GYFTiLsME/hqdefault.jpg)](https://www.youtube.com/watch?v=87GYFTiLsME)\n\n## Features\n\n- [X] Detects finger positions using antennas\n- [X] Scales frequencies to a musical range\n- [X] Generates sound based on finger distances\n- [X] Uses a button to change sounds\n- [ ] Automatic scaling\n- [ ] Uploading custom waveforms\n- [ ] Increasing detection range\n- [ ] Ddecorelator implementation\n\n## Frequency Detection\n\nFrequency detection is performed by measuring the time interval between each signal period. When the signal changes state, a timer starts counting until the next rising edge. An interrupt then captures the counter value and stores it in memory.\n\n![Frequency detector](doc/freq_det.png)\n\nAdditionally, DMA transfers these values into an buffer. Once the DMA transfer completes, an interrupt is triggered every `FREQ_DET_DMA_BUFFER_NUM` transfers. This buffer is then processed for frequency analysis and oscillators tuning.\n\n## Capacitive Touch Calibration\n\nEach antenna generates a digital square wave signal with a frequency between 400 kHz and 600 kHz. The `het_generator` module processes these signals by quantizing them to create a beating signal with a frequency above 10 kHz.\n\nTo calibrate the system, measure the base frequency of each antenna and define `HET_GENX_FREQ` for each channel with an offset of approximately 20 kHz.\n\nFor example, if the measured base frequencies are:\n\n```\nANTENNA 0: 530000 Hz  \nANTENNA 1: 614000 Hz  \nANTENNA 2: 520000 Hz  \nANTENNA 3: 510000 Hz  \n```\n\nYou should set:\n\n```c\n#define HET_GEN0_FREQ 550000  \n#define HET_GEN1_FREQ 634000  \n#define HET_GEN2_FREQ 540000  \n#define HET_GEN3_FREQ 530000  \n```\n\nThis calibration method is somewhat tricky, but it is the best available approach for now. Improving the calibration process is on my to-do list. 😊\n\n## Direct Digital Synthesis\n\nThe program includes four independent oscillators mixed using the `dds` module. Each oscillator retrieves samples from a wavetable at a frequency set by a phase accumulator.\n\nTo create custom waveforms, I use the [Wave Table Generator](http://www.gaudi.ch/WaveGenerator/) and my own scripts to generate sine waves and their combinations.\n\n## Building the Project\n\nFirst, clone the repository and initialize all submodules (FreeRTOS and CMSIS) using the following commands:\n\n```sh\ngit submodule init  \ngit submodule update  \n```\n\nThere are multiple ways to build the project.\n\n### Using VS Code Extension (Recommended)\n\nFollow the official SDK documentation to install the [Raspberry Pi Pico VS Code extension](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#vscode-extension).\n\nThen, clone the repository and open it in Visual Studio Code. Next, import the project using the Raspberry Pi Pico badge. Select the project location and click the `Import` button. If the Pico SDK is not yet installed, the extension may take a few minutes to download and set it up.\n\n![Example of project import](doc/import_project.png)\n\nAfter reloading the window, the board configuration should be loaded as `polyTheremin_board`.\n\n### Using CMake\n\nYou can also build the project manually using CMake. Create a build folder and run `cmake` inside it:\n\n```sh\nmkdir build  \ncd build  \ncmake ..  \nmake  \n```\n\n## Contributing\n\nContributions to this project are welcome! Feel free to submit a pull request or create a new issue. I strive to write clean and efficient code, but code reviews and feedback are always appreciated to enhance the project further. 😊\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicyg%2Fpolytheremin_software","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicyg%2Fpolytheremin_software","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicyg%2Fpolytheremin_software/lists"}