You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
282 B
13 lines
282 B
import io
|
|
import mido
|
|
|
|
|
|
def load_midi_from_bytes(content: bytes) -> mido.MidiFile:
|
|
return mido.MidiFile(file=io.BytesIO(content))
|
|
|
|
|
|
def midi_to_bytes(midi: mido.MidiFile) -> bytes:
|
|
buffer = io.BytesIO()
|
|
midi.save(file=buffer)
|
|
buffer.seek(0)
|
|
return buffer.read()
|