Install
TestPyPI for CPython, the MIP index for boards# CPython: audiodsp comes along from PyPI
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ omnipython-audioinstruments
# MicroPython, on a firmware that has audiodsp in it
import mip
mip.install("audioinstruments", index="https://PyDevices.github.io/mip")
Both are pure Python. On a board they need a firmware built with audiodsp, whose nodes they are made of.
Try this first
Middle C on a Poly106import audiocore
import audioinstruments
inst = audioinstruments.create("poly106", 48000)
print(inst.macro_labels[:4])
inst.note_on(60, 100)
for n in range(6):
inst.fill()
result, data = audiocore.get_buffer(inst.output, False, 0)
samples = memoryview(bytes(data)).cast("h")
print(n, max(abs(s) for s in samples))
inst.deinit()
That plays middle C on the Poly106 and prints its first four knobs, then the loudest sample of each buffer as the note sounds. Each instrument is a patch of oscillators, filters and envelopes on a virtual rack; audioinstruments.ALL lists every name create() takes. To shape the sound afterwards, add audioeffects, and to play the library in a DAW, install MPVST.
Read more
Depth lives in the repositoryOverview
What an instrument is and how a patch becomes sound.
The instruments
Every synthesizer, organ, electric piano and drum machine, by name.
Patching
Building and changing a patch on the rack.
audiodsp
The CircuitPython-compatible audio nodes underneath.