9009a7c5bc
- Created type stubs for various modules in the mido library including messages, midifiles, parser, ports, sockets, syx, tokenizer, and version. - Implemented type hints for functions and classes to improve type checking and code clarity. - Added support for MIDI over TCP/IP in sockets module. - Included methods for reading and writing SYX files in syx module. - Enhanced the parser functionality with a dedicated Parser class for MIDI byte streams. - Established a structure for MIDI file handling with MidiFile and MidiTrack classes.
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).
|
|
"""
|