Debian Codegraph @

docs/backends/custom.rst

raw
1 .. SPDX-FileCopyrightText: 2013 Ole Martin Bjorndalen <[email protected]>
2 ..
3 .. SPDX-License-Identifier: CC-BY-4.0
4
5 Writing a New or Custom Backend
6 -------------------------------
7
8 A backend is a Python module with one or more of these::
9
10 Input -- an input port class
11 Output -- an output port class
12 IOPort -- an I/O port class
13 get_devices() -- returns a list of devices
14
15 Once written, the backend can be used by setting the environment
16 variable ``MIDO_BACKEND`` or by calling ``mido.set_backend()``. In
17 both cases, the path of the module is used.
18
19 ``Input``
20
21 And input class for ``open_input()``. This is only required if the
22 backend supports input.
23
24 ``Output``
25
26 And output class for ``open_output()``. This is only required if the
27 backend supports output.
28
29 ``IOPort``
30
31 An I/O port class for ``open_ioport()``. If this is not found,
32 ``open_ioport()`` will return ``mido.ports.IOPort(Input(),
33 Output())``.
34
35 ``get_devices(**kwargs)``
36
37 Returns a list of devices, where each device is dictionary with at
38 least these three values::
39
40 {
41 'name': 'Some MIDI Input Port',
42 'is_input': True,
43 'is_output': False,
44 }
45
46 These are used to build return values for ``get_input_names()`` etc..
47 This function will also be available to the user directly.
48
49 For examples, see ``mido/backends/``.