midiscripter 0.2__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.
Files changed (48) hide show
  1. midiscripter-0.2/LICENSE +165 -0
  2. midiscripter-0.2/PKG-INFO +262 -0
  3. midiscripter-0.2/README.md +63 -0
  4. midiscripter-0.2/midiscripter/__init__.py +9 -0
  5. midiscripter-0.2/midiscripter/base/__init__.py +0 -0
  6. midiscripter-0.2/midiscripter/base/msg_base.py +95 -0
  7. midiscripter-0.2/midiscripter/base/port_base.py +251 -0
  8. midiscripter-0.2/midiscripter/base/shared.py +62 -0
  9. midiscripter-0.2/midiscripter/cli/__init__.py +1 -0
  10. midiscripter-0.2/midiscripter/cli/starters.py +41 -0
  11. midiscripter-0.2/midiscripter/file_event/__init__.py +2 -0
  12. midiscripter-0.2/midiscripter/file_event/file_event_msg.py +49 -0
  13. midiscripter-0.2/midiscripter/file_event/file_event_port.py +76 -0
  14. midiscripter-0.2/midiscripter/gui/__init__.py +11 -0
  15. midiscripter-0.2/midiscripter/gui/app.py +111 -0
  16. midiscripter-0.2/midiscripter/gui/gui_widgets/__init__.py +0 -0
  17. midiscripter-0.2/midiscripter/gui/gui_widgets/button.py +177 -0
  18. midiscripter-0.2/midiscripter/gui/gui_widgets/gui_msg.py +55 -0
  19. midiscripter-0.2/midiscripter/gui/gui_widgets/gui_widget_base.py +169 -0
  20. midiscripter-0.2/midiscripter/gui/gui_widgets/layout.py +63 -0
  21. midiscripter-0.2/midiscripter/gui/gui_widgets/list.py +67 -0
  22. midiscripter-0.2/midiscripter/gui/gui_widgets/mixins.py +114 -0
  23. midiscripter-0.2/midiscripter/gui/gui_widgets/text.py +52 -0
  24. midiscripter-0.2/midiscripter/gui/log_widget.py +156 -0
  25. midiscripter-0.2/midiscripter/gui/main_window.py +125 -0
  26. midiscripter-0.2/midiscripter/gui/menu_bar.py +206 -0
  27. midiscripter-0.2/midiscripter/gui/ports_widget.py +309 -0
  28. midiscripter-0.2/midiscripter/keyboard/__init__.py +4 -0
  29. midiscripter-0.2/midiscripter/keyboard/keyboard_msg.py +117 -0
  30. midiscripter-0.2/midiscripter/keyboard/keyboard_port.py +103 -0
  31. midiscripter-0.2/midiscripter/logger/__init__.py +3 -0
  32. midiscripter-0.2/midiscripter/logger/console_sink.py +55 -0
  33. midiscripter-0.2/midiscripter/logger/html_sink.py +61 -0
  34. midiscripter-0.2/midiscripter/logger/log.py +128 -0
  35. midiscripter-0.2/midiscripter/metronome/__init__.py +1 -0
  36. midiscripter-0.2/midiscripter/metronome/metronome_port.py +72 -0
  37. midiscripter-0.2/midiscripter/midi/__init__.py +4 -0
  38. midiscripter-0.2/midiscripter/midi/midi_msg.py +182 -0
  39. midiscripter-0.2/midiscripter/midi/midi_note_data.py +104 -0
  40. midiscripter-0.2/midiscripter/midi/midi_port.py +183 -0
  41. midiscripter-0.2/midiscripter/midi/midi_ports_update.py +56 -0
  42. midiscripter-0.2/midiscripter/osc/__init__.py +3 -0
  43. midiscripter-0.2/midiscripter/osc/osc_msg.py +42 -0
  44. midiscripter-0.2/midiscripter/osc/osc_port.py +95 -0
  45. midiscripter-0.2/midiscripter/osc/osc_query_maker.py +53 -0
  46. midiscripter-0.2/midiscripter/resources/icon.ico +0 -0
  47. midiscripter-0.2/midiscripter/resources/icon.svg +19 -0
  48. midiscripter-0.2/pyproject.toml +62 -0
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,262 @@
1
+ Metadata-Version: 2.3
2
+ Name: midiscripter
3
+ Version: 0.2
4
+ Summary: Framework for scripting MIDI, keyboard and Open Sound Control input and output
5
+ Project-URL: Documentation, https://maboroshy.github.io/midi-scripter
6
+ Project-URL: Issues, https://github.com/Maboroshy/midi-scripter/issues
7
+ Project-URL: Source, https://github.com/Maboroshy/midi-scripter
8
+ Author: Maboroshy
9
+ License: GNU LESSER GENERAL PUBLIC LICENSE
10
+ Version 3, 29 June 2007
11
+
12
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
13
+ Everyone is permitted to copy and distribute verbatim copies
14
+ of this license document, but changing it is not allowed.
15
+
16
+
17
+ This version of the GNU Lesser General Public License incorporates
18
+ the terms and conditions of version 3 of the GNU General Public
19
+ License, supplemented by the additional permissions listed below.
20
+
21
+ 0. Additional Definitions.
22
+
23
+ As used herein, "this License" refers to version 3 of the GNU Lesser
24
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
25
+ General Public License.
26
+
27
+ "The Library" refers to a covered work governed by this License,
28
+ other than an Application or a Combined Work as defined below.
29
+
30
+ An "Application" is any work that makes use of an interface provided
31
+ by the Library, but which is not otherwise based on the Library.
32
+ Defining a subclass of a class defined by the Library is deemed a mode
33
+ of using an interface provided by the Library.
34
+
35
+ A "Combined Work" is a work produced by combining or linking an
36
+ Application with the Library. The particular version of the Library
37
+ with which the Combined Work was made is also called the "Linked
38
+ Version".
39
+
40
+ The "Minimal Corresponding Source" for a Combined Work means the
41
+ Corresponding Source for the Combined Work, excluding any source code
42
+ for portions of the Combined Work that, considered in isolation, are
43
+ based on the Application, and not on the Linked Version.
44
+
45
+ The "Corresponding Application Code" for a Combined Work means the
46
+ object code and/or source code for the Application, including any data
47
+ and utility programs needed for reproducing the Combined Work from the
48
+ Application, but excluding the System Libraries of the Combined Work.
49
+
50
+ 1. Exception to Section 3 of the GNU GPL.
51
+
52
+ You may convey a covered work under sections 3 and 4 of this License
53
+ without being bound by section 3 of the GNU GPL.
54
+
55
+ 2. Conveying Modified Versions.
56
+
57
+ If you modify a copy of the Library, and, in your modifications, a
58
+ facility refers to a function or data to be supplied by an Application
59
+ that uses the facility (other than as an argument passed when the
60
+ facility is invoked), then you may convey a copy of the modified
61
+ version:
62
+
63
+ a) under this License, provided that you make a good faith effort to
64
+ ensure that, in the event an Application does not supply the
65
+ function or data, the facility still operates, and performs
66
+ whatever part of its purpose remains meaningful, or
67
+
68
+ b) under the GNU GPL, with none of the additional permissions of
69
+ this License applicable to that copy.
70
+
71
+ 3. Object Code Incorporating Material from Library Header Files.
72
+
73
+ The object code form of an Application may incorporate material from
74
+ a header file that is part of the Library. You may convey such object
75
+ code under terms of your choice, provided that, if the incorporated
76
+ material is not limited to numerical parameters, data structure
77
+ layouts and accessors, or small macros, inline functions and templates
78
+ (ten or fewer lines in length), you do both of the following:
79
+
80
+ a) Give prominent notice with each copy of the object code that the
81
+ Library is used in it and that the Library and its use are
82
+ covered by this License.
83
+
84
+ b) Accompany the object code with a copy of the GNU GPL and this license
85
+ document.
86
+
87
+ 4. Combined Works.
88
+
89
+ You may convey a Combined Work under terms of your choice that,
90
+ taken together, effectively do not restrict modification of the
91
+ portions of the Library contained in the Combined Work and reverse
92
+ engineering for debugging such modifications, if you also do each of
93
+ the following:
94
+
95
+ a) Give prominent notice with each copy of the Combined Work that
96
+ the Library is used in it and that the Library and its use are
97
+ covered by this License.
98
+
99
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
100
+ document.
101
+
102
+ c) For a Combined Work that displays copyright notices during
103
+ execution, include the copyright notice for the Library among
104
+ these notices, as well as a reference directing the user to the
105
+ copies of the GNU GPL and this license document.
106
+
107
+ d) Do one of the following:
108
+
109
+ 0) Convey the Minimal Corresponding Source under the terms of this
110
+ License, and the Corresponding Application Code in a form
111
+ suitable for, and under terms that permit, the user to
112
+ recombine or relink the Application with a modified version of
113
+ the Linked Version to produce a modified Combined Work, in the
114
+ manner specified by section 6 of the GNU GPL for conveying
115
+ Corresponding Source.
116
+
117
+ 1) Use a suitable shared library mechanism for linking with the
118
+ Library. A suitable mechanism is one that (a) uses at run time
119
+ a copy of the Library already present on the user's computer
120
+ system, and (b) will operate properly with a modified version
121
+ of the Library that is interface-compatible with the Linked
122
+ Version.
123
+
124
+ e) Provide Installation Information, but only if you would otherwise
125
+ be required to provide such information under section 6 of the
126
+ GNU GPL, and only to the extent that such information is
127
+ necessary to install and execute a modified version of the
128
+ Combined Work produced by recombining or relinking the
129
+ Application with a modified version of the Linked Version. (If
130
+ you use option 4d0, the Installation Information must accompany
131
+ the Minimal Corresponding Source and Corresponding Application
132
+ Code. If you use option 4d1, you must provide the Installation
133
+ Information in the manner specified by section 6 of the GNU GPL
134
+ for conveying Corresponding Source.)
135
+
136
+ 5. Combined Libraries.
137
+
138
+ You may place library facilities that are a work based on the
139
+ Library side by side in a single library together with other library
140
+ facilities that are not Applications and are not covered by this
141
+ License, and convey such a combined library under terms of your
142
+ choice, if you do both of the following:
143
+
144
+ a) Accompany the combined library with a copy of the same work based
145
+ on the Library, uncombined with any other library facilities,
146
+ conveyed under the terms of this License.
147
+
148
+ b) Give prominent notice with the combined library that part of it
149
+ is a work based on the Library, and explaining where to find the
150
+ accompanying uncombined form of the same work.
151
+
152
+ 6. Revised Versions of the GNU Lesser General Public License.
153
+
154
+ The Free Software Foundation may publish revised and/or new versions
155
+ of the GNU Lesser General Public License from time to time. Such new
156
+ versions will be similar in spirit to the present version, but may
157
+ differ in detail to address new problems or concerns.
158
+
159
+ Each version is given a distinguishing version number. If the
160
+ Library as you received it specifies that a certain numbered version
161
+ of the GNU Lesser General Public License "or any later version"
162
+ applies to it, you have the option of following the terms and
163
+ conditions either of that published version or of any later version
164
+ published by the Free Software Foundation. If the Library as you
165
+ received it does not specify a version number of the GNU Lesser
166
+ General Public License, you may choose any version of the GNU Lesser
167
+ General Public License ever published by the Free Software Foundation.
168
+
169
+ If the Library as you received it specifies that a proxy can decide
170
+ whether future versions of the GNU Lesser General Public License shall
171
+ apply, that proxy's public statement of acceptance of any version is
172
+ permanent authorization for you to choose that version for the
173
+ Library.
174
+ License-File: LICENSE
175
+ Keywords: MIDI,OSC,automation,input,script
176
+ Classifier: Development Status :: 4 - Beta
177
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
178
+ Classifier: Operating System :: Microsoft :: Windows
179
+ Classifier: Programming Language :: Python
180
+ Classifier: Programming Language :: Python :: 3.11
181
+ Classifier: Programming Language :: Python :: 3.12
182
+ Classifier: Programming Language :: Python :: Implementation :: CPython
183
+ Classifier: Topic :: Multimedia :: Sound/Audio
184
+ Classifier: Topic :: Multimedia :: Sound/Audio :: MIDI
185
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
186
+ Requires-Python: >=3.11
187
+ Requires-Dist: colorama~=0.4
188
+ Requires-Dist: pynput~=1.7
189
+ Requires-Dist: pyside6-essentials<6.7,>6.4
190
+ Requires-Dist: python-osc~=1.7
191
+ Requires-Dist: python-rtmidi~=1.5
192
+ Requires-Dist: pywin32; platform_system == 'Windows'
193
+ Requires-Dist: watchdog~=4.0
194
+ Provides-Extra: doc
195
+ Requires-Dist: griffe-inherited-docstrings; extra == 'doc'
196
+ Requires-Dist: mkdocs-material; extra == 'doc'
197
+ Requires-Dist: mkdocstrings; extra == 'doc'
198
+ Description-Content-Type: text/markdown
199
+
200
+ # MIDI Scripter
201
+
202
+ MIDI Scripter is a framework for scripting MIDI, keyboard and Open Sound Control (OSC) input and output with a few lines of Python code.
203
+
204
+ MIDI Scripter is intended for digital audio workstation (DAW) controls scripting but can also be used for general input conversion and automation. It fits where controller mappings are not enough but rewriting DAW controller integration is too much.
205
+
206
+ An octave transposer with GUI controls in 10 lines of code:
207
+
208
+ ``` python
209
+ from midiscripter import * # safe * import with no bloat
210
+
211
+ midi_keyboard = MidiIn('Port name') # GUI will provide you with port names
212
+ proxy_output = MidiOut('loopMIDI Port') # using loopMIDI virtual port for output
213
+
214
+ # GUI control in a single line, many widget available, custom widgets supported
215
+ octave_selector = GuiButtonSelectorH(('-2', '-1', '0', '+1', '+2'), select='0')
216
+
217
+ @midi_keyboard.subscribe # decorated function will receive port's messages
218
+ def transpose(msg: MidiMsg) -> None:
219
+ if msg.type == MidiType.NOTE_ON or msg.type == MidiType.NOTE_OFF: # filter
220
+ msg.data1 += 12 * int(octave_selector.selected_item_text) # modify
221
+ proxy_output.send(msg) # route
222
+
223
+ if __name__ == '__main__': # combine multiple scripts by importing them
224
+ start_gui() # opens helpful customizable GUI
225
+ ```
226
+
227
+ ![Screenshot](https://github.com/Maboroshy/midi-scripter/blob/master/examples/octave_transposer/screenshot.png?raw=true)
228
+
229
+ [Scripting guide and API documentation available](https://maboroshy.github.io/midi-scripter)
230
+
231
+ Easy tasks for MIDI Scripter:
232
+ 1. Filter, modify and route MIDI, OSC and keyboard messages in any way.
233
+ 2. Map MIDI, OSC and keyboard to each other.
234
+ 3. Map any Python code to input message.
235
+ 4. Make extra "shift" keys to multiply MIDI controls.
236
+ 5. Organize mappings into sets / scenes with GUI controls.
237
+ 6. Make an extra overlay mappings on top of MIDI controller's default DAW integration by using proxy.
238
+
239
+ Complex tasks for MIDI Scripter:
240
+ 1. Create and map complex macros involving multiple hardware or virtual MIDI controllers.
241
+ 2. Make custom sequencer or MIDI input generator.
242
+ 3. Make music education ot trainer GUI application based on MIDI input.
243
+
244
+ Currently MIDI Scripter is at "beta" development stage. It's fully functional but needs some more testing. It targets only Windows for now but Linux and macOS support will follow.
245
+
246
+ ## Installation
247
+ 1. [Python 3.11+](https://www.python.org/downloads/) with "Add python.exe to PATH" option.
248
+ 2. [loopMIDI](https://www.tobias-erichsen.de/software/loopmidi.html) for virtual MIDI output ports on Windows.
249
+ 3. `pip install midiscripter` in console.
250
+
251
+ ## Setup
252
+ Run loopMIDI and add virtual ports you want to send MIDI messages. You can enable its autostart option.
253
+
254
+ Enable virtual MIDI output ports as MIDI inputs in DAW.
255
+
256
+ ## Quick Start
257
+ 1. Paste [script template](examples/script_template.py) to Python IDE or plain text editor. IDE is greatly recommended.
258
+ 2. Run unchanged template script from IDE or by `python .\script_template.py` to open GUI for more info on available ports and their input.
259
+ 3. Turn on the ports' checkboxes to enable them and watch the log for input messages.
260
+ 4. Click on port names and messages to copy their declarations to the clipboard. Paste the declarations to your script.
261
+ 5. Write the functions you need. Subscribe them to messages with `@input_port.subscribe` decorator. Use `log('messages')` for debugging. Use `output_port.send(msg)` to send modified or created messages from a function.
262
+ 6. Restart the script from GUI.
@@ -0,0 +1,63 @@
1
+ # MIDI Scripter
2
+
3
+ MIDI Scripter is a framework for scripting MIDI, keyboard and Open Sound Control (OSC) input and output with a few lines of Python code.
4
+
5
+ MIDI Scripter is intended for digital audio workstation (DAW) controls scripting but can also be used for general input conversion and automation. It fits where controller mappings are not enough but rewriting DAW controller integration is too much.
6
+
7
+ An octave transposer with GUI controls in 10 lines of code:
8
+
9
+ ``` python
10
+ from midiscripter import * # safe * import with no bloat
11
+
12
+ midi_keyboard = MidiIn('Port name') # GUI will provide you with port names
13
+ proxy_output = MidiOut('loopMIDI Port') # using loopMIDI virtual port for output
14
+
15
+ # GUI control in a single line, many widget available, custom widgets supported
16
+ octave_selector = GuiButtonSelectorH(('-2', '-1', '0', '+1', '+2'), select='0')
17
+
18
+ @midi_keyboard.subscribe # decorated function will receive port's messages
19
+ def transpose(msg: MidiMsg) -> None:
20
+ if msg.type == MidiType.NOTE_ON or msg.type == MidiType.NOTE_OFF: # filter
21
+ msg.data1 += 12 * int(octave_selector.selected_item_text) # modify
22
+ proxy_output.send(msg) # route
23
+
24
+ if __name__ == '__main__': # combine multiple scripts by importing them
25
+ start_gui() # opens helpful customizable GUI
26
+ ```
27
+
28
+ ![Screenshot](https://github.com/Maboroshy/midi-scripter/blob/master/examples/octave_transposer/screenshot.png?raw=true)
29
+
30
+ [Scripting guide and API documentation available](https://maboroshy.github.io/midi-scripter)
31
+
32
+ Easy tasks for MIDI Scripter:
33
+ 1. Filter, modify and route MIDI, OSC and keyboard messages in any way.
34
+ 2. Map MIDI, OSC and keyboard to each other.
35
+ 3. Map any Python code to input message.
36
+ 4. Make extra "shift" keys to multiply MIDI controls.
37
+ 5. Organize mappings into sets / scenes with GUI controls.
38
+ 6. Make an extra overlay mappings on top of MIDI controller's default DAW integration by using proxy.
39
+
40
+ Complex tasks for MIDI Scripter:
41
+ 1. Create and map complex macros involving multiple hardware or virtual MIDI controllers.
42
+ 2. Make custom sequencer or MIDI input generator.
43
+ 3. Make music education ot trainer GUI application based on MIDI input.
44
+
45
+ Currently MIDI Scripter is at "beta" development stage. It's fully functional but needs some more testing. It targets only Windows for now but Linux and macOS support will follow.
46
+
47
+ ## Installation
48
+ 1. [Python 3.11+](https://www.python.org/downloads/) with "Add python.exe to PATH" option.
49
+ 2. [loopMIDI](https://www.tobias-erichsen.de/software/loopmidi.html) for virtual MIDI output ports on Windows.
50
+ 3. `pip install midiscripter` in console.
51
+
52
+ ## Setup
53
+ Run loopMIDI and add virtual ports you want to send MIDI messages. You can enable its autostart option.
54
+
55
+ Enable virtual MIDI output ports as MIDI inputs in DAW.
56
+
57
+ ## Quick Start
58
+ 1. Paste [script template](examples/script_template.py) to Python IDE or plain text editor. IDE is greatly recommended.
59
+ 2. Run unchanged template script from IDE or by `python .\script_template.py` to open GUI for more info on available ports and their input.
60
+ 3. Turn on the ports' checkboxes to enable them and watch the log for input messages.
61
+ 4. Click on port names and messages to copy their declarations to the clipboard. Paste the declarations to your script.
62
+ 5. Write the functions you need. Subscribe them to messages with `@input_port.subscribe` decorator. Use `log('messages')` for debugging. Use `output_port.send(msg)` to send modified or created messages from a function.
63
+ 6. Restart the script from GUI.
@@ -0,0 +1,9 @@
1
+ from .base.shared import restart_script, run_after_ports_opened
2
+ from .cli import *
3
+ from .file_event import *
4
+ from .gui import *
5
+ from .keyboard import *
6
+ from .logger import *
7
+ from .metronome import *
8
+ from .midi import *
9
+ from .osc import *
File without changes
@@ -0,0 +1,95 @@
1
+ import enum
2
+ from typing import Optional
3
+ from collections.abc import Container
4
+
5
+ import midiscripter.base.shared
6
+ from midiscripter.base.port_base import Input
7
+
8
+
9
+ class AttrEnum(enum.StrEnum):
10
+ def __repr__(self):
11
+ return f'{self.__class__.__name__}({self.value.__repr__()})'
12
+
13
+
14
+ class Msg:
15
+ """The data object generated by input port that is sent as an argument to it's registered calls
16
+ and can be sent with an output port."""
17
+
18
+ type: str
19
+ """Message type description for filtering and representation"""
20
+
21
+ ctime: float
22
+ """Message creation time in epoch format"""
23
+
24
+ source: Input
25
+ """Input port instance that generated the message."""
26
+
27
+ __match_args__: tuple[str] = ('type',)
28
+
29
+ def __init__(self, type: str, source: Input | None = None):
30
+ """
31
+ Args:
32
+ source: Input port instance that generated the message
33
+ """
34
+ self.type = type
35
+ self.source = source
36
+ self.ctime = midiscripter.base.shared.precise_epoch_time()
37
+
38
+ self.ctime: float # workaround for mkdocstrings issue #607
39
+ """Message creation time in epoch format"""
40
+
41
+ def __repr__(self):
42
+ return f'{self.__class__.__name__}({", ".join(str(value) for value in self.__as_tuple())})'
43
+
44
+ def __str__(self):
45
+ return ' | '.join(str(value) for value in self.__as_tuple() if value is not None)
46
+
47
+ def __eq__(self, other_msg: 'Msg'):
48
+ return type(self) is type(other_msg) and self.__as_tuple() == other_msg.__as_tuple()
49
+
50
+ def matches(self, *args_conditions, **kwargs_conditions) -> bool:
51
+ """Checks if message's attributes match all provided attribute conditions:
52
+ 1. If condition is `None` or omitted it matches anything.
53
+ 2. If condition equals attribute it matches the attribute.
54
+ 3. If condition is a container and contains the message attribute it matches the attribute.
55
+
56
+ Returns:
57
+ True if all attribute match, False if any are not
58
+ """
59
+ attr_conditions = dict(zip(self.__match_args__, args_conditions, strict=False))
60
+ attr_conditions.update(kwargs_conditions)
61
+
62
+ for parameter, condition in attr_conditions.items():
63
+ if condition is None:
64
+ continue
65
+
66
+ try:
67
+ attr = getattr(self, parameter)
68
+ except AttributeError:
69
+ continue
70
+
71
+ if attr == condition:
72
+ continue
73
+
74
+ if (
75
+ isinstance(condition, Container)
76
+ and not isinstance(condition, str)
77
+ and attr in condition
78
+ ):
79
+ continue
80
+
81
+ return False
82
+ return True
83
+
84
+ @property
85
+ def _age_ms(self) -> float:
86
+ """Time passed since message creation in milliseconds."""
87
+ return round((midiscripter.base.shared.precise_epoch_time() - self.ctime) * 1000, 3)
88
+
89
+ def __as_tuple(self) -> tuple:
90
+ """Converts message to a tuple based on message's __match_args__ class attribute
91
+
92
+ Returns:
93
+ Tuple with values of attributes specified in __match_args__ class attribute.
94
+ """
95
+ return tuple(getattr(self, attr_name) for attr_name in self.__match_args__)