File: syx.rst

package info (click to toggle)
python-mido 1.3.3-0.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 920 kB
  • sloc: python: 4,006; makefile: 127; sh: 4
file content (44 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
.. SPDX-FileCopyrightText: 2014 Ole Martin Bjorndalen <ombdalen@gmail.com>
..
.. SPDX-License-Identifier: CC-BY-4.0

SYX Files
=========

SYX files are used to store :term:`SysEx` messages, usually for patch data.


Reading and Writing
-------------------

To read a ``SYX`` file::

    messages = mido.read_syx_file('patch.syx')

To write a ``SYX`` file::

    mido.write_syx_file('patch.syx', messages)

Non-sysex messages will be ignored.


Plain Text Format
-----------------

Mido also supports *plain text* SYX files. These are read in exactly the
same way::

    messages = mido.read_syx_file('patch.txt')

``read_syx_file()`` determines which format the file is by looking at
the first byte.  It raises ``ValueError`` if file is plain text and byte
is not a 2-digit hex number.

To write plain text::

    mido.write_syx_file('patch.txt', messages, plaintext=True)

This will write the messages as hex encoded bytes with one message per line::

    F0 00 01 5D 02 00 F7
    F0 00 01 5D 03 00 F7