29 lines
820 B
Python
29 lines
820 B
Python
|
|
"""
|
||
|
|
Read and write SYX file format
|
||
|
|
"""
|
||
|
|
|
||
|
|
from _typeshed import FileDescriptorOrPath
|
||
|
|
|
||
|
|
from .messages import Message
|
||
|
|
|
||
|
|
def read_syx_file(filename: FileDescriptorOrPath) -> list[Message]:
|
||
|
|
"""Read sysex messages from SYX file.
|
||
|
|
|
||
|
|
Returns a list of sysex messages.
|
||
|
|
|
||
|
|
This handles both the text (hexadecimal) and binary
|
||
|
|
formats. Messages other than sysex will be ignored. Raises
|
||
|
|
ValueError if file is plain text and byte is not a 2-digit hex
|
||
|
|
number.
|
||
|
|
"""
|
||
|
|
|
||
|
|
def write_syx_file(filename: FileDescriptorOrPath, messages: list[Message], plaintext: bool = False) -> None:
|
||
|
|
"""Write sysex messages to a SYX file.
|
||
|
|
|
||
|
|
Messages other than sysex will be skipped.
|
||
|
|
|
||
|
|
By default this will write the binary format. Pass
|
||
|
|
`plaintext=True` to write the plain text format (hex encoded
|
||
|
|
ASCII text).
|
||
|
|
"""
|