pymididefs 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .claude/settings.local.json
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Simon Holliday
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: pymididefs
3
+ Version: 0.2.4
4
+ Summary: Comprehensive MIDI 1.0 and 2.0 constant definitions for Python.
5
+ Project-URL: Homepage, https://github.com/simonholliday/PyMidiDefs
6
+ Project-URL: Repository, https://github.com/simonholliday/PyMidiDefs
7
+ Project-URL: Issues, https://github.com/simonholliday/PyMidiDefs/issues
8
+ Author: Simon Holliday
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: constants,definitions,general-midi,midi,midi2,music
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Multimedia :: Sound/Audio :: MIDI
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Provides-Extra: dev
25
+ Requires-Dist: mypy; extra == 'dev'
26
+ Requires-Dist: pytest; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # PyMidiDefs
30
+
31
+ Comprehensive MIDI 1.0 and 2.0 constant definitions for Python.
32
+
33
+ A zero-dependency reference library providing named constants, lookup
34
+ dictionaries, and utility functions for the MIDI specification. Covers
35
+ note numbers, Control Change assignments, General MIDI instruments and
36
+ percussion, status bytes, Standard MIDI File meta-events, MIDI 2.0
37
+ Universal MIDI Packet (UMP) message types, and MIDI-CI capability inquiry
38
+ constants.
39
+
40
+ ## Why PyMidiDefs?
41
+
42
+ If you're building a Python synthesiser, sequencer, DAW, MIDI controller
43
+ interface, music generator, or any application that sends or receives MIDI
44
+ messages, you need the same set of protocol constants: note numbers, CC
45
+ assignments, program change values, status bytes. These numbers are defined
46
+ by the MIDI specification and never change, yet most projects end up
47
+ re-defining them from scratch or copying them from unreliable sources.
48
+
49
+ PyMidiDefs gives you a single, authoritative package with every constant
50
+ sourced directly from the official MIDI specifications. It
51
+ has no runtime dependencies and works with any MIDI library or framework --
52
+ python-rtmidi, mido, pygame.midi, or your own socket-level implementation.
53
+
54
+ ## About MIDI
55
+
56
+ MIDI (Musical Instrument Digital Interface) is a technical standard for
57
+ communication between electronic musical instruments, computers, and audio
58
+ devices. It was conceived in the early 1980s by Dave Smith of Sequential
59
+ Circuits and Ikutaro Kakehashi of Roland, who proposed a Universal
60
+ Synthesizer Interface to allow instruments from different manufacturers to
61
+ talk to each other. The MIDI 1.0 Detailed Specification was published in
62
+ August 1983 by the International MIDI Association (now the MIDI
63
+ Manufacturers Association, MMA) and has remained backwards-compatible ever
64
+ since.
65
+
66
+ General MIDI (GM), standardised in 1991, defined a common set of 128
67
+ instrument sounds and a percussion key map so that a MIDI file created on
68
+ one device would sound broadly similar on another. The Standard MIDI File
69
+ (SMF) format, also formalised in the early 1990s, became the universal way
70
+ to store and exchange MIDI sequences.
71
+
72
+ In January 2020, the MIDI Association announced MIDI 2.0 -- the first major
73
+ update to the protocol in nearly four decades. MIDI 2.0 introduces the
74
+ Universal MIDI Packet (UMP) format with higher-resolution velocity and
75
+ controller values, per-note controllers, and bidirectional communication via
76
+ MIDI-CI (Capability Inquiry) for automatic device configuration, profile
77
+ negotiation, and property exchange. MIDI 2.0 is a strict superset of MIDI
78
+ 1.0; all existing MIDI 1.0 definitions remain valid.
79
+
80
+ ## Installation
81
+
82
+ ```bash
83
+ pip install git+https://github.com/simonholliday/PyMidiDefs.git
84
+ ```
85
+
86
+ ## Modules
87
+
88
+ | Module | Description |
89
+ |--------|-------------|
90
+ | `pymididefs.notes` | MIDI note numbers (C-1 to G9) and name/number conversion |
91
+ | `pymididefs.cc` | Control Change number assignments (0-127), plus 14-bit pack/unpack helpers |
92
+ | `pymididefs.rpn` | Standard Registered Parameter Numbers (RPN) and the 14-bit parameter conventions shared with NRPN |
93
+ | `pymididefs.drums` | General MIDI Level 1 percussion key map |
94
+ | `pymididefs.gm` | General MIDI Level 1 instrument program numbers and families |
95
+ | `pymididefs.status` | MIDI 1.0 status bytes (channel voice, system common, system real-time) |
96
+ | `pymididefs.meta` | Standard MIDI File meta-event type bytes |
97
+ | `pymididefs.ump` | MIDI 2.0 Universal MIDI Packet message types and constants |
98
+ | `pymididefs.ci` | MIDI 2.0 Capability Inquiry (MIDI-CI) constants |
99
+
100
+ ## Usage
101
+
102
+ ```python
103
+ import pymididefs.notes
104
+ import pymididefs.cc
105
+ import pymididefs.drums
106
+ import pymididefs.gm
107
+
108
+ # Note constants
109
+ pymididefs.notes.C4 # 60 (Middle C)
110
+ pymididefs.notes.A4 # 69 (Concert pitch)
111
+
112
+ # Note name conversion
113
+ pymididefs.notes.note_to_name(60) # "C4"
114
+ pymididefs.notes.name_to_note("Db4") # 61
115
+
116
+ # Control Change numbers
117
+ pymididefs.cc.SUSTAIN_PEDAL # 64
118
+ pymididefs.cc.FILTER_CUTOFF # 74
119
+ pymididefs.cc.CC_MAP["pan"] # 10
120
+
121
+ # GM percussion
122
+ pymididefs.drums.KICK_1 # 36
123
+ pymididefs.drums.HI_HAT_CLOSED # 42
124
+ pymididefs.drums.GM_DRUM_MAP["snare_1"] # 38
125
+ pymididefs.drums.KICK # 36 (unnumbered "primary" alias of KICK_1)
126
+ pymididefs.drums.GM_DRUM_PRIMARY_ALIASES["crash"] # 49
127
+
128
+ # GM instruments
129
+ pymididefs.gm.ACOUSTIC_GRAND_PIANO # 0
130
+ pymididefs.gm.VIOLIN # 40
131
+ pymididefs.gm.GM_INSTRUMENT_NAMES[40] # "Violin"
132
+ pymididefs.gm.GM_INSTRUMENT_MAP["flute"] # 73
133
+ ```
134
+
135
+ ### RPN and 14-bit values
136
+
137
+ ```python
138
+ import pymididefs.rpn
139
+ import pymididefs.cc
140
+
141
+ # Standard Registered Parameter Numbers
142
+ pymididefs.rpn.PITCH_BEND_SENSITIVITY # 0
143
+ pymididefs.rpn.MODULATION_DEPTH_RANGE # 5 (added in GM2)
144
+ pymididefs.rpn.NULL_PARAMETER # 16383 (sent as MSB=127, LSB=127)
145
+
146
+ # 14-bit pack/unpack — works for any MIDI 1.0 14-bit value
147
+ # (Bank Select, Data Entry, RPN/NRPN parameter numbers, pitch bend, ...)
148
+ pymididefs.cc.pack_14bit(8192) # (64, 0) pitch bend centre
149
+ pymididefs.cc.unpack_14bit(64, 0) # 8192
150
+ ```
151
+
152
+ ### MIDI 2.0
153
+
154
+ ```python
155
+ import pymididefs.ump
156
+ import pymididefs.ci
157
+
158
+ # Universal MIDI Packet message types
159
+ pymididefs.ump.MIDI2_CHANNEL_VOICE # 0x4
160
+ pymididefs.ump.NOTE_ON # 0x9
161
+ pymididefs.ump.PROTOCOL_MIDI2 # 0x02
162
+
163
+ # MIDI-CI
164
+ pymididefs.ci.DISCOVERY # 0x70
165
+ pymididefs.ci.PROFILE_INQUIRY # 0x20
166
+ ```
167
+
168
+ ## Sources
169
+
170
+ All definitions are sourced from the official MIDI specifications published by
171
+ the [MIDI Association](https://midi.org/specs):
172
+
173
+ - [MIDI 1.0 Detailed Specification](https://midi.org/midi-1-0-detailed-specification) (MMA/AMEI)
174
+ - [General MIDI Level 1 Specification](https://midi.org/general-midi-level-1)
175
+ - [General MIDI 2 Specification](https://midi.org/general-midi-2)
176
+ - [Standard MIDI File 1.0 Specification](https://midi.org/standard-midi-files)
177
+ - [M2-104-UM v1.1 — Universal MIDI Packet (UMP) Format and MIDI 2.0 Protocol Specification](https://midi.org/universal-midi-packet-ump-and-midi-2-0-protocol-specification)
178
+ - [M2-101-UM v1.2 — MIDI-CI Specification](https://midi.org/midi-ci-specification)
179
+
180
+ Some specifications require a free [MIDI Association membership](https://midi.org/membership)
181
+ to download.
182
+
183
+ ## License
184
+
185
+ MIT -- you are free to use, copy, modify, merge, publish, distribute,
186
+ sublicense, and sell copies of this software in any project, including
187
+ commercial and closed-source applications. The only requirement is that you include the
188
+ LICENSE file when redistributing the software. See [LICENSE](LICENSE)
189
+ for the full text.
@@ -0,0 +1,161 @@
1
+ # PyMidiDefs
2
+
3
+ Comprehensive MIDI 1.0 and 2.0 constant definitions for Python.
4
+
5
+ A zero-dependency reference library providing named constants, lookup
6
+ dictionaries, and utility functions for the MIDI specification. Covers
7
+ note numbers, Control Change assignments, General MIDI instruments and
8
+ percussion, status bytes, Standard MIDI File meta-events, MIDI 2.0
9
+ Universal MIDI Packet (UMP) message types, and MIDI-CI capability inquiry
10
+ constants.
11
+
12
+ ## Why PyMidiDefs?
13
+
14
+ If you're building a Python synthesiser, sequencer, DAW, MIDI controller
15
+ interface, music generator, or any application that sends or receives MIDI
16
+ messages, you need the same set of protocol constants: note numbers, CC
17
+ assignments, program change values, status bytes. These numbers are defined
18
+ by the MIDI specification and never change, yet most projects end up
19
+ re-defining them from scratch or copying them from unreliable sources.
20
+
21
+ PyMidiDefs gives you a single, authoritative package with every constant
22
+ sourced directly from the official MIDI specifications. It
23
+ has no runtime dependencies and works with any MIDI library or framework --
24
+ python-rtmidi, mido, pygame.midi, or your own socket-level implementation.
25
+
26
+ ## About MIDI
27
+
28
+ MIDI (Musical Instrument Digital Interface) is a technical standard for
29
+ communication between electronic musical instruments, computers, and audio
30
+ devices. It was conceived in the early 1980s by Dave Smith of Sequential
31
+ Circuits and Ikutaro Kakehashi of Roland, who proposed a Universal
32
+ Synthesizer Interface to allow instruments from different manufacturers to
33
+ talk to each other. The MIDI 1.0 Detailed Specification was published in
34
+ August 1983 by the International MIDI Association (now the MIDI
35
+ Manufacturers Association, MMA) and has remained backwards-compatible ever
36
+ since.
37
+
38
+ General MIDI (GM), standardised in 1991, defined a common set of 128
39
+ instrument sounds and a percussion key map so that a MIDI file created on
40
+ one device would sound broadly similar on another. The Standard MIDI File
41
+ (SMF) format, also formalised in the early 1990s, became the universal way
42
+ to store and exchange MIDI sequences.
43
+
44
+ In January 2020, the MIDI Association announced MIDI 2.0 -- the first major
45
+ update to the protocol in nearly four decades. MIDI 2.0 introduces the
46
+ Universal MIDI Packet (UMP) format with higher-resolution velocity and
47
+ controller values, per-note controllers, and bidirectional communication via
48
+ MIDI-CI (Capability Inquiry) for automatic device configuration, profile
49
+ negotiation, and property exchange. MIDI 2.0 is a strict superset of MIDI
50
+ 1.0; all existing MIDI 1.0 definitions remain valid.
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ pip install git+https://github.com/simonholliday/PyMidiDefs.git
56
+ ```
57
+
58
+ ## Modules
59
+
60
+ | Module | Description |
61
+ |--------|-------------|
62
+ | `pymididefs.notes` | MIDI note numbers (C-1 to G9) and name/number conversion |
63
+ | `pymididefs.cc` | Control Change number assignments (0-127), plus 14-bit pack/unpack helpers |
64
+ | `pymididefs.rpn` | Standard Registered Parameter Numbers (RPN) and the 14-bit parameter conventions shared with NRPN |
65
+ | `pymididefs.drums` | General MIDI Level 1 percussion key map |
66
+ | `pymididefs.gm` | General MIDI Level 1 instrument program numbers and families |
67
+ | `pymididefs.status` | MIDI 1.0 status bytes (channel voice, system common, system real-time) |
68
+ | `pymididefs.meta` | Standard MIDI File meta-event type bytes |
69
+ | `pymididefs.ump` | MIDI 2.0 Universal MIDI Packet message types and constants |
70
+ | `pymididefs.ci` | MIDI 2.0 Capability Inquiry (MIDI-CI) constants |
71
+
72
+ ## Usage
73
+
74
+ ```python
75
+ import pymididefs.notes
76
+ import pymididefs.cc
77
+ import pymididefs.drums
78
+ import pymididefs.gm
79
+
80
+ # Note constants
81
+ pymididefs.notes.C4 # 60 (Middle C)
82
+ pymididefs.notes.A4 # 69 (Concert pitch)
83
+
84
+ # Note name conversion
85
+ pymididefs.notes.note_to_name(60) # "C4"
86
+ pymididefs.notes.name_to_note("Db4") # 61
87
+
88
+ # Control Change numbers
89
+ pymididefs.cc.SUSTAIN_PEDAL # 64
90
+ pymididefs.cc.FILTER_CUTOFF # 74
91
+ pymididefs.cc.CC_MAP["pan"] # 10
92
+
93
+ # GM percussion
94
+ pymididefs.drums.KICK_1 # 36
95
+ pymididefs.drums.HI_HAT_CLOSED # 42
96
+ pymididefs.drums.GM_DRUM_MAP["snare_1"] # 38
97
+ pymididefs.drums.KICK # 36 (unnumbered "primary" alias of KICK_1)
98
+ pymididefs.drums.GM_DRUM_PRIMARY_ALIASES["crash"] # 49
99
+
100
+ # GM instruments
101
+ pymididefs.gm.ACOUSTIC_GRAND_PIANO # 0
102
+ pymididefs.gm.VIOLIN # 40
103
+ pymididefs.gm.GM_INSTRUMENT_NAMES[40] # "Violin"
104
+ pymididefs.gm.GM_INSTRUMENT_MAP["flute"] # 73
105
+ ```
106
+
107
+ ### RPN and 14-bit values
108
+
109
+ ```python
110
+ import pymididefs.rpn
111
+ import pymididefs.cc
112
+
113
+ # Standard Registered Parameter Numbers
114
+ pymididefs.rpn.PITCH_BEND_SENSITIVITY # 0
115
+ pymididefs.rpn.MODULATION_DEPTH_RANGE # 5 (added in GM2)
116
+ pymididefs.rpn.NULL_PARAMETER # 16383 (sent as MSB=127, LSB=127)
117
+
118
+ # 14-bit pack/unpack — works for any MIDI 1.0 14-bit value
119
+ # (Bank Select, Data Entry, RPN/NRPN parameter numbers, pitch bend, ...)
120
+ pymididefs.cc.pack_14bit(8192) # (64, 0) pitch bend centre
121
+ pymididefs.cc.unpack_14bit(64, 0) # 8192
122
+ ```
123
+
124
+ ### MIDI 2.0
125
+
126
+ ```python
127
+ import pymididefs.ump
128
+ import pymididefs.ci
129
+
130
+ # Universal MIDI Packet message types
131
+ pymididefs.ump.MIDI2_CHANNEL_VOICE # 0x4
132
+ pymididefs.ump.NOTE_ON # 0x9
133
+ pymididefs.ump.PROTOCOL_MIDI2 # 0x02
134
+
135
+ # MIDI-CI
136
+ pymididefs.ci.DISCOVERY # 0x70
137
+ pymididefs.ci.PROFILE_INQUIRY # 0x20
138
+ ```
139
+
140
+ ## Sources
141
+
142
+ All definitions are sourced from the official MIDI specifications published by
143
+ the [MIDI Association](https://midi.org/specs):
144
+
145
+ - [MIDI 1.0 Detailed Specification](https://midi.org/midi-1-0-detailed-specification) (MMA/AMEI)
146
+ - [General MIDI Level 1 Specification](https://midi.org/general-midi-level-1)
147
+ - [General MIDI 2 Specification](https://midi.org/general-midi-2)
148
+ - [Standard MIDI File 1.0 Specification](https://midi.org/standard-midi-files)
149
+ - [M2-104-UM v1.1 — Universal MIDI Packet (UMP) Format and MIDI 2.0 Protocol Specification](https://midi.org/universal-midi-packet-ump-and-midi-2-0-protocol-specification)
150
+ - [M2-101-UM v1.2 — MIDI-CI Specification](https://midi.org/midi-ci-specification)
151
+
152
+ Some specifications require a free [MIDI Association membership](https://midi.org/membership)
153
+ to download.
154
+
155
+ ## License
156
+
157
+ MIT -- you are free to use, copy, modify, merge, publish, distribute,
158
+ sublicense, and sell copies of this software in any project, including
159
+ commercial and closed-source applications. The only requirement is that you include the
160
+ LICENSE file when redistributing the software. See [LICENSE](LICENSE)
161
+ for the full text.
@@ -0,0 +1,34 @@
1
+ """PyMidiDefs — comprehensive MIDI 1.0 and 2.0 constant definitions for Python.
2
+
3
+ A zero-dependency reference library covering the MIDI 1.0 Detailed Specification,
4
+ General MIDI Level 1, Universal MIDI Packet (UMP) format, and MIDI-CI.
5
+
6
+ Modules
7
+ -------
8
+ notes — MIDI note numbers and name/number conversion.
9
+ cc — Control Change number assignments and 14-bit pack/unpack helpers.
10
+ rpn — Standard Registered Parameter Numbers and the 14-bit parameter conventions shared with NRPN.
11
+ drums — General MIDI Level 1 percussion key map.
12
+ gm — General MIDI Level 1 instrument program numbers and families.
13
+ status — MIDI 1.0 status bytes (channel voice, system common, system real-time).
14
+ meta — Standard MIDI File meta-event type bytes.
15
+ ump — MIDI 2.0 Universal MIDI Packet message types and constants.
16
+ ci — MIDI 2.0 Capability Inquiry (MIDI-CI) constants.
17
+ """
18
+
19
+ import importlib.metadata
20
+
21
+ import pymididefs.notes
22
+
23
+ # Version is derived from the latest git tag at build time via hatch-vcs;
24
+ # `importlib.metadata` then reads it from the installed package metadata.
25
+ # The fallback only fires if someone runs from a raw source checkout without
26
+ # installing the package (e.g. directly from a git clone with no `pip install`).
27
+ try:
28
+ __version__ = importlib.metadata.version("pymididefs")
29
+ except importlib.metadata.PackageNotFoundError:
30
+ __version__ = "0.0.0+unknown"
31
+
32
+ # Convenience re-exports for the most common operations.
33
+ note_to_name = pymididefs.notes.note_to_name
34
+ name_to_note = pymididefs.notes.name_to_note