File: panic.py

package info (click to toggle)
python-rtmidi 1.5.8-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,248 kB
  • sloc: cpp: 4,228; python: 2,853; makefile: 287; sh: 109; ansic: 19
file content (28 lines) | stat: -rw-r--r-- 765 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
27
28
#!/usr/bin/env python
#
# panic.py
#
"""Send AllSoundOff and ResetAllControllers on all JACK MIDI outputs and all channels."""

from __future__ import print_function

import time

import rtmidi
from rtmidi.midiconstants import (ALL_SOUND_OFF, CONTROL_CHANGE,
                                  RESET_ALL_CONTROLLERS)


midiout = rtmidi.MidiOut(rtapi=rtmidi.API_UNIX_JACK)
print(__doc__)

for portnum, portname in enumerate(midiout.get_ports()):
    print("Port:", portname)

    with midiout.open_port(portnum):
        for channel in range(16):
            midiout.send_message([CONTROL_CHANGE | channel, ALL_SOUND_OFF, 0])
            midiout.send_message([CONTROL_CHANGE | channel, RESET_ALL_CONTROLLERS, 0])
            time.sleep(0.05)

        time.sleep(0.1)