CARVIEW |
Select Language
HTTP/2 200
date: Wed, 30 Jul 2025 22:17:57 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"8618519fbfd39e7d58ecad7ab1a6b9b4"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=qWtbKhBcEeB8ByyizU2MUCSSJP6T5nZMdgtW%2FXKImAHFLHNh9A4EmSSme%2BNpd74x6AjyID8pUQEY9TmUqhBkJtClzGzsLHkXi4pjK4cTR51YRKUM8uZ2%2BQpKadPEQ6rz2ncT9cVfHzpaYCxSPEYXc%2FX7oyldkY4Yg7HqywBglBH73WgUVrwEWDezO8qRyzK2XN8vTHoP7ND5pOwwkyI%2BrWJ97E8CzYAnVoszrTR%2BpetdD1VWrF8aEU2%2FxMciMpHQxls4D33Je%2F8XRcknPEg42Q%3D%3D--son1JZ8ni5rQjYI8--aYsfhfMOoFYkedzlDOIv9w%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.74199260.1753913876; Path=/; Domain=github.com; Expires=Thu, 30 Jul 2026 22:17:56 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 30 Jul 2026 22:17:56 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: BD7A:DB217:7E215:B845A:688A9A14
Trinkey MIDI Theremin with Pitch! (will also work on any other CircuitPython devices with `touchio`) · GitHub
Show Gist options
Save todbot/bb4ec9c509f8c301e4787e5cb26ec870 to your computer and use it in GitHub Desktop.
{{ message }}
Instantly share code, notes, and snippets.
Last active
November 8, 2024 16:20
-
Star
2
(2)
You must be signed in to star a gist -
Fork
1
(1)
You must be signed in to fork a gist
-
Save todbot/bb4ec9c509f8c301e4787e5cb26ec870 to your computer and use it in GitHub Desktop.
Trinkey MIDI Theremin with Pitch! (will also work on any other CircuitPython devices with `touchio`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# trinkey_theremin_pitch_code.py -- Trinkey MIDI Theremin! with pitch control! | |
# 2021 @todbot | |
# left antenna: pitch (by multiple MIDI notes, put your synth in legato mode) | |
# right antenna: filter cutoff | |
# video demo in comment below | |
# | |
import time | |
import board | |
import neopixel | |
import touchio | |
import usb_midi | |
import adafruit_midi | |
from adafruit_midi.note_on import NoteOn | |
from adafruit_midi.control_change import ControlChange | |
midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=0) | |
leds = neopixel.NeoPixel(board.NEOPIXEL, 4, brightness=0.2, auto_write=True) | |
# announce we're alive and wait for things to stabilize | |
# before creating touch pins so their raw_value baseline are okay | |
leds.fill(0xff00ff) | |
time.sleep(1.0) | |
leds.fill(0) | |
touch1_pin = touchio.TouchIn(board.TOUCH1) | |
touch2_pin = touchio.TouchIn(board.TOUCH2) | |
# a litlte helper class for noise filtering | |
class RunningAverage: | |
def __init__(self,count): | |
self.count = count | |
self.i = 0 | |
self.buf = [0] * self.count | |
def add_value(self,val): | |
self.buf[self.i] = val | |
self.i = (self.i + 1) % self.count | |
def average(self): | |
return sum(self.buf)/self.count | |
base1 = int(touch1_pin.raw_value * 1.02) | |
base2 = int(touch2_pin.raw_value * 1.02) | |
avg1 = RunningAverage(8) | |
avg2 = RunningAverage(8) | |
note_on = False | |
note_base = 48 # C3 in MIDI land | |
note = note_base | |
velocity = 64 # half | |
while True: | |
avg1.add_value( touch1_pin.raw_value ) | |
avg2.add_value( touch2_pin.raw_value ) | |
r = 0 | |
g = min(max(avg1.average()-base1, 0),255) | |
b = min(max(avg2.average()-base2, 0),255) | |
leds.fill( (r,g,b) ) | |
if g > 10: # hand present | |
note_new = note_base + int(g/4) | |
if note_new != note: | |
print(time.monotonic(),"******* ON! ",note_new,note) | |
midi.send(NoteOn(note_new, velocity)) # turn on new note | |
midi.send(NoteOn(note,0)) # 0=off # turn off old note | |
note = note_new # save new note | |
else: # no hand, turn off note | |
midi.send(NoteOn(note,0)) # 0=off | |
if b > 10: # hand present | |
midi.send(ControlChange( 74, 16+int(b/2.5))) # 74 = filter cutoff | |
time.sleep(0.001) |
yes "theramin" is spelled wrong :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can’t perform that action at this time.
Video demo of above code:
trinkey_midi_theramin.mp4