audioinstruments

Synthesizers, organs and electric pianos, each one a patch on a virtual rack.

Each instrument is a module, audioinstruments.<name>, exposing:

MACRO_LABELS  tuple of names, one per macro parameter
MACRO_MODES   {index: "UNIPOLAR" | "BIPOLAR" | "TOGGLE"}
PATCHES       {index: (name, (macro values, 0-127))}; patch 0 is the sound
              a freshly created instrument makes
NOTE_MAP      drum machines only: ((midi_note, label), ...)
PAD_MAP       drum machines only: ((key, voice), ...) for pad keys 36-51
create(sample_rate, channel_count=2, transport=None, **options)

import audioinstruments
inst = audioinstruments.create("poly106", 48000)
inst.note_on(60)
inst.set_macro(0, 96)            # vcf_freq, MIDI scale
audio_out.play(inst.output)

On MicroPython call inst.fill() every 10 to 20 ms while it plays: that is when notes and knobs reach the sound. Where the patch compiles to an audiograph graph, inst.output is the graph and renders as it is pulled; otherwise it is a ring that fill() keeps topped up. The options are those of audioinstruments._rack.adapter.Instrument (voices, block_size, output, engine and the rest), or of audioinstruments._rack.soundfont.create for the SAMPLERS.

audioinstruments.create(name, sample_rate, channel_count=2, transport=None, **options)[source]

Load instrument name and return a live instance of it.

audioinstruments.load(name)[source]

Import and return the instrument module name.