32 lines
888 B
Python
32 lines
888 B
Python
# SPDX-FileCopyrightText: 2023 John Park and @todbot / Tod Kurt
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import time
|
|
import board
|
|
import digitalio
|
|
import synthio
|
|
|
|
# for PWM audio with an RC filter
|
|
# import audiopwmio
|
|
# audio = audiopwmio.PWMAudioOut(board.GP10)
|
|
|
|
# for I2S audio with external I2S DAC board
|
|
import audiobusio
|
|
|
|
# I2S on Audio BFF or Amp BFF on QT Py:
|
|
# audio = audiobusio.I2SOut(bit_clock=board.A3, word_select=board.A2, data=board.A1)
|
|
|
|
# I2S audio on PropMaker Feather RP2040
|
|
power = digitalio.DigitalInOut(board.EXTERNAL_POWER)
|
|
power.switch_to_output(value=True)
|
|
audio = audiobusio.I2SOut(board.I2S_BIT_CLOCK, board.I2S_WORD_SELECT, board.I2S_DATA)
|
|
|
|
synth = synthio.Synthesizer(sample_rate=44100)
|
|
audio.play(synth)
|
|
|
|
while True:
|
|
synth.press((65, 69, 72)) # midi note 65 = F4
|
|
time.sleep(1)
|
|
synth.release((65, 69, 72)) # release the note we pressed
|
|
time.sleep(2)
|