File: use_printer.py

package info (click to toggle)
python-mido 1.3.3-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 920 kB
  • sloc: python: 4,006; makefile: 127; sh: 4
file content (26 lines) | stat: -rw-r--r-- 629 bytes parent folder | download
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
# SPDX-FileCopyrightText: 2014 Ole Martin Bjorndalen <ombdalen@gmail.com>
#
# SPDX-License-Identifier: MIT

"""
Try out the new printer port backend.

It also works with MIDO_BACKEND, so you can do:

    $ MIDO_BACKEND=printer python
    >>> import mido
    >>> mido.get_output_names()
    ['The Printer Port']
"""
import mido

mido.set_backend('printer')

print(f'Available outputs: {mido.get_output_names()!r}')

with mido.open_output() as port:
    print(f'Using {port}.')

    port.send(mido.Message('program_change', program=10))
    for i in [1, 2, 3]:
        port.send(mido.Message('control_change', control=1, value=i))