Skip to content

Instantly share code, notes, and snippets.

@benevpi
Created July 23, 2021 14:54
Show Gist options
  • Select an option

  • Save benevpi/7652c0f11c9f898e20217a957148bc59 to your computer and use it in GitHub Desktop.

Select an option

Save benevpi/7652c0f11c9f898e20217a957148bc59 to your computer and use it in GitHub Desktop.
import time
import board
import busio
import usb_midi
import adafruit_midi
from adafruit_midi.note_on import NoteOn
from adafruit_midi.note_off import NoteOff
import random
USB_MIDI_channel = 1 # pick your USB MIDI out channel here, 1-16
usb_midi = adafruit_midi.MIDI(
midi_out=usb_midi.ports[1], out_channel=USB_MIDI_channel - 1
)
counter = 0
current_note=10
while True:
# read all the knob values
counter = counter+1
if (counter == 100) :
usb_midi.send(NoteOff(current_note, 10))
current_note = random.randint(0,100)
usb_midi.send(NoteOn(current_note, 10))
counter = 0
time.sleep(0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment