Skip to content

Instantly share code, notes, and snippets.

@dglaude
Created August 22, 2023 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dglaude/36f540a2b2776b69901c1ab908410e65 to your computer and use it in GitHub Desktop.
Save dglaude/36f540a2b2776b69901c1ab908410e65 to your computer and use it in GitHub Desktop.
My Pico DV Base 3 buttons drums
"""Three button drum machine on Pico DV base"""
import time
import board
from digitalio import DigitalInOut, Direction, Pull
from adafruit_debouncer import Debouncer
import synthio
import audiobusio
import audiomixer
import drums
led = DigitalInOut(board.LED)
led.direction = Direction.OUTPUT
### import board ###
### from digitalio import DigitalInOut, Direction, Pull ###
pin_button_A = DigitalInOut(board.BUTTON_A)
pin_button_A.direction = Direction.INPUT
pin_button_A.pull = Pull.DOWN
pin_button_B = DigitalInOut(board.BUTTON_B)
pin_button_B.direction = Direction.INPUT
pin_button_B.pull = Pull.DOWN
pin_button_C = DigitalInOut(board.BUTTON_C)
pin_button_C.direction = Direction.INPUT
pin_button_C.pull = Pull.DOWN
### from adafruit_debouncer import Debouncer ###
switch_A = Debouncer(pin_button_A)
switch_B = Debouncer(pin_button_B)
switch_C = Debouncer(pin_button_C)
### import audiobusio ###
audio = audiobusio.I2SOut(bit_clock=board.GP27, word_select=board.GP28, data=board.GP26)
### import audiomixer ###
mixer = audiomixer.Mixer(sample_rate=22050, buffer_size=2048, channel_count=1)
synth = synthio.Synthesizer(sample_rate=22050, channel_count=1)
audio.play(mixer)
mixer.voice[0].play(synth)
mixer.voice[0].level = 0.25 # 25% volume might be better
### import drums ###
kick_drum=drums.KickDrum(synth)
snare=drums.Snare(synth)
#snare.setLPF(8500)
high_hat=drums.HighHat(synth)
#high_hat=drums.HighHat(synth, t=0.230)
#high_hat.setHPF(8000)
while True:
switch_A.update()
switch_B.update()
switch_C.update()
if switch_A.rose:
kick_drum.play()
if switch_B.rose:
snare.play()
if switch_C.rose:
high_hat.play()
@dglaude
Copy link
Author

dglaude commented Aug 22, 2023

To use this you need:

  • a "pico dv" board from Pimoroni
  • a raspberry Pi Pico (not the Pico W version)
  • an headset
  • the file drums.py from @gamblor21
  • this code.py file from @dglaude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment