Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
doing the blink1

Tod Kurt todbot

💭
doing the blink1
View GitHub Profile
@todbot
todbot / synthio_filter_test3.py
Last active June 7, 2023 22:20
dueling bandpass filters with new synthio filters using CircuitPython
View synthio_filter_test3.py
# synthio_filter_test3.py -- dueling bandpass filters
# 7 Jun 2023 - @todbot / Tod Kurt
# video demo: https://www.youtube.com/watch?v=wIc6rovZ4aA
import time, board, audiopwmio, audiomixer, synthio
audio = audiopwmio.PWMAudioOut(board.GP10)
mixer = audiomixer.Mixer(channel_count=1, sample_rate=22050, buffer_size=2048)
synth = synthio.Synthesizer(sample_rate=22050)
audio.play(mixer)
mixer.voice[0].play(synth)
@todbot
todbot / wavetable_synthio_synth.py
Last active June 7, 2023 00:46
Demonstrate new synthio.Synthesizer as wavetable MIDI synth in CircuitPython
View wavetable_synthio_synth.py
#
# wavetable_synthio_synth.py -- Demonstrate new synthio.Synthesizer as wavetable MIDI synth
# 15 Apr 2023 - @todbot / Tod Kurt
# video demo: https://www.youtube.com/watch?v=uUnS3nR2K-8
#
# Hooked up to generic I2S DAC
# Uses two pots:
# knobA - selects the base wave
# knobB - selects the mix between base wave and next wave
#
@todbot
todbot / synthio_two_knob_drone_synth.py
Last active June 6, 2023 19:46
Got a Pico and two pots? Now you got a drone synth. In CircuitPython of course
View synthio_two_knob_drone_synth.py
# synthio_two_knob_drone_synth.py -- Got a Pico and two pots? Now you got a drone synth
# 5 Jun 2023 - @todbot / Tod Kurt
# video demo: https://www.youtube.com/watch?v=KsSRaKjhmHg
import time, random, board, analogio, audiopwmio, synthio
knob1 = analogio.AnalogIn(board.GP26)
knob2 = analogio.AnalogIn(board.GP27)
audio = audiopwmio.PWMAudioOut(board.GP10)
synth = synthio.Synthesizer(sample_rate=22050)
@todbot
todbot / synthio_filter_test.py
Created June 6, 2023 00:40
trying out new synthio filter PR, knobs control frequency and resonance, in CircuitPython
View synthio_filter_test.py
# synthio_filter_test.py -- trying out new filter PR, knobs control frequency and resonance
# 5 Jun 2023 - @todbot / Tod Kurt
import time, random, board, analogio, audiopwmio, synthio
audio = audiopwmio.PWMAudioOut(board.GP10)
synth = synthio.Synthesizer(sample_rate=22050)
audio.play(synth)
knob1 = analogio.AnalogIn(board.GP26)
knob2 = analogio.AnalogIn(board.GP27)
@todbot
todbot / synthio_tiny_lfo_song.py
Last active June 5, 2023 06:27
tiny "song" made with just LFOs in synthio in CircuitPython
View synthio_tiny_lfo_song.py
# synthio_tiny_lfo_song.py -- tiny "song" made with just LFOs in synthio
# 29 May 2023 - @todbot / Tod Kurt
# video demo: https://www.youtube.com/watch?v=m_ALNCWXor0
# requires CircuitPython 8.2.0-beta0 or later
import board, time, audiopwmio, synthio, random
audio = audiopwmio.PWMAudioOut(board.GP10)
synth = synthio.Synthesizer(sample_rate=22050)
audio.play(synth)
lfo_tremo1 = synthio.LFO(rate=3) # 3 Hz for fastest note
@todbot
todbot / dual_i2s_player.py
Last active June 4, 2023 23:53
Demonstrate using two I2S stereo DACs at once on RP2040 / Raspberry Pi Pico in CircuitPython
View dual_i2s_player.py
# dual_i2s_player.py -- demonstrate using two I2S stereo DACs at once on RP2040 / Raspberry Pi Pico
# 19 May 2023 - @todbot / Tod Kurt
# video of this code: https://www.youtube.com/watch?v=CgqECxhqJEo
import time, board, audiocore, audiobusio
# qtpy rp2040 pins
# in this case, board.* names just match silkscreen, don't indicate functionality
lck1_pin, bck1_pin, dat1_pin = board.MISO, board.MOSI, board.SCK
lck2_pin, bck2_pin, dat2_pin = board.SCL, board.SDA, board.TX
@todbot
todbot / udp_recv_code.py
Last active June 3, 2023 01:07
UDP sender and receiver in CircuitPython
View udp_recv_code.py
# udp_recv_code.py -- receive UDP messages from any receiver, can be another CircuitPython device
# 24 Aug 2022 - @todbot / Tod Kurt
# cribbing from code at https://github.com/adafruit/circuitpython/blob/main/tests/circuitpython-manual/socketpool/datagram/ntp.py
import time, wifi, socketpool
from secrets import secrets
print("Connecting to WiFi...")
wifi.radio.connect(ssid=secrets['ssid'],password=secrets['password'])
print("my IP addr:", wifi.radio.ipv4_address)
pool = socketpool.SocketPool(wifi.radio)
@todbot
todbot / synthio_midi_synth.py
Last active June 2, 2023 02:27
pretty usable MIDI-controlled synth using synthio in CircuitPython
View synthio_midi_synth.py
# synthio_midi_synth.py - pretty usable MIDI-controlled synth using synthio in CircuitPython
# 11 May 2023 - @todbot / Tod Kurt
# Uses cheapie PCM5102 DAC on QTPY RP2040
# Video demo: https://www.youtube.com/watch?v=N-PbbWWDE6k
# Features:
# - midi velocity controls attack rate (gentle press = slow, hard press = fast)
# - notes have small random detune on all oscillators to reduce phase stacking
# - adjustable number of detuned oscillators per note 1-5 (midi controller 83)
# - five selectable waveforms: saw, squ, sin, noisy sin, noise (midi controller 82)
# - vibrato depth on mod wheel (midi controller 1)
@todbot
todbot / mqtt_demo_code.py
Created October 10, 2021 18:47
CircuitPython MQTT demo using public.cloud.shiftr.io
View mqtt_demo_code.py
# mqtt_demo_code.py -- MQTT demo using public.cloud.shiftr.io
# 9 Oct 2021 - @todbot
#
# Uses LEDs on Adafruit Funhouse but adaptable to any CircuitPython WiFi board.
#
# To see what's going on, download MQTT-Explorer from http://mqtt-explorer.com/
# Launch it and connect to the MQTT host/port/username/password as in secrets below.
#
# From MQTT-Explorer, you should see messages to "todbot/feeds/hello" every 3 seconds
# And then you can go to the right of MQTT-Explorer to Publish, fill in "todbot/feeds/light",
@todbot
todbot / emoji_flipper.py
Last active May 27, 2023 07:55
Show a bunch of emojis from a sprite sheet in CircuitPython
View emoji_flipper.py
# emoji_flipper.py - show a bunch of emojis from a sprite sheet
# 23 Jun 2022 - @todbot / Tod Kurt
import time
import board
import displayio
sprite_fname = "emoji_spritesheet_27x7_28x28.bmp"
sprite_cnt = 27*7
sprite_w,sprite_h = 28,28