Jeff Epler 12c1a72f03
synthio: implement envelope
This works for me (tested playing midi to raw files on host computer, as
well as a variant of the nunchuk instrument on pygamer)

it has to re-factor how/when MIDI reading occurs, because reasons.

endorse new test results

.. and allow `-1` to specify a note with no sustain (plucked)
2023-04-25 12:05:53 -05:00

23 lines
540 B
Python

import array
try:
from synthio import MidiTrack
from audiocore import get_buffer, get_structure
except ImportError:
print("SKIP")
raise SystemExit
SCORE = b"\0\x90@\0\x20\x90b\0\x20\x80@\0\0\x80\b\0"
with MidiTrack(SCORE, sample_rate=8000, tempo=640) as m:
print(get_structure(m))
p, q = get_buffer(m)
print(p, list(q))
with MidiTrack(
SCORE, sample_rate=8000, tempo=640, waveform=array.array("h", [0, 32767, 0, -32768])
) as m:
print(get_structure(m))
p, q = get_buffer(m)
print(p, list(q))