File: custom.rst

package info (click to toggle)
python-mido 1.3.3-0.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 920 kB
  • sloc: python: 4,006; makefile: 127; sh: 4
file content (49 lines) | stat: -rw-r--r-- 1,357 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
45
46
47
48
49
.. SPDX-FileCopyrightText: 2013 Ole Martin Bjorndalen <ombdalen@gmail.com>
..
.. SPDX-License-Identifier: CC-BY-4.0

Writing a New or Custom Backend
-------------------------------

A backend is a Python module with one or more of these::

    Input -- an input port class
    Output -- an output port class
    IOPort -- an I/O port class
    get_devices() -- returns a list of devices

Once written, the backend can be used by setting the environment
variable ``MIDO_BACKEND`` or by calling ``mido.set_backend()``. In
both cases, the path of the module is used.

``Input``

   And input class for ``open_input()``. This is only required if the
   backend supports input.

``Output``

   And output class for ``open_output()``. This is only required if the
   backend supports output.

``IOPort``

   An I/O port class for ``open_ioport()``. If this is not found,
   ``open_ioport()`` will return ``mido.ports.IOPort(Input(),
   Output())``.

``get_devices(**kwargs)``

   Returns a list of devices, where each device is dictionary with at
   least these three values::

      {
        'name': 'Some MIDI Input Port',
        'is_input': True,
        'is_output': False,
      }

   These are used to build return values for ``get_input_names()`` etc..
   This function will also be available to the user directly.

For examples, see ``mido/backends/``.