circuitpython-tmidi 1.0.1__tar.gz → 1.0.3__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 (44) hide show
  1. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/PKG-INFO +2 -2
  2. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/circuitpython_tmidi.egg-info/PKG-INFO +2 -2
  3. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/circuitpython_tmidi.egg-info/SOURCES.txt +1 -0
  4. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/conf.py +2 -2
  5. circuitpython_tmidi-1.0.3/docs/examples.rst +18 -0
  6. circuitpython_tmidi-1.0.3/examples/tmidi_simple_receiver.py +17 -0
  7. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/pyproject.toml +1 -1
  8. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/tmidi.py +28 -22
  9. circuitpython_tmidi-1.0.1/docs/examples.rst +0 -8
  10. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +0 -0
  11. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.github/workflows/build.yml +0 -0
  12. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.github/workflows/failure-help-text.yml +0 -0
  13. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.github/workflows/release_gh.yml +0 -0
  14. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.github/workflows/release_pypi.yml +0 -0
  15. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.gitignore +0 -0
  16. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.pre-commit-config.yaml +0 -0
  17. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.pylintrc +0 -0
  18. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/.readthedocs.yaml +0 -0
  19. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/CODE_OF_CONDUCT.md +0 -0
  20. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/LICENSE +0 -0
  21. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/LICENSES/CC-BY-4.0.txt +0 -0
  22. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/LICENSES/MIT.txt +0 -0
  23. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/LICENSES/Unlicense.txt +0 -0
  24. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/README.rst +0 -0
  25. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/README.rst.license +0 -0
  26. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/circuitpython_tmidi.egg-info/dependency_links.txt +0 -0
  27. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/circuitpython_tmidi.egg-info/requires.txt +0 -0
  28. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/circuitpython_tmidi.egg-info/top_level.txt +0 -0
  29. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/_static/favicon.ico +0 -0
  30. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/_static/favicon.ico.license +0 -0
  31. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/api.rst +0 -0
  32. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/api.rst.license +0 -0
  33. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/examples.rst.license +0 -0
  34. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/index.rst +0 -0
  35. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/index.rst.license +0 -0
  36. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/docs/requirements.txt +0 -0
  37. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/examples/tmidi_midiforwarder.py +0 -0
  38. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/examples/tmidi_multiple_receiver.py +0 -0
  39. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/examples/tmidi_simpletest.py +0 -0
  40. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/optional_requirements.txt +0 -0
  41. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/requirements.txt +0 -0
  42. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/setup.cfg +0 -0
  43. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/tests/test_one.py +0 -0
  44. {circuitpython_tmidi-1.0.1 → circuitpython_tmidi-1.0.3}/tests/test_tmidi_one.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: circuitpython-tmidi
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: MIDI library for CircuitPython
5
5
  Author-email: Tod Kurt <tod@todbot.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: circuitpython-tmidi
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: MIDI library for CircuitPython
5
5
  Author-email: Tod Kurt <tod@todbot.com>
6
6
  License: MIT
@@ -35,6 +35,7 @@ docs/_static/favicon.ico
35
35
  docs/_static/favicon.ico.license
36
36
  examples/tmidi_midiforwarder.py
37
37
  examples/tmidi_multiple_receiver.py
38
+ examples/tmidi_simple_receiver.py
38
39
  examples/tmidi_simpletest.py
39
40
  tests/test_one.py
40
41
  tests/test_tmidi_one.py
@@ -112,10 +112,10 @@ napoleon_numpy_docstring = False
112
112
  # The theme to use for HTML and HTML Help pages. See the documentation for
113
113
  # a list of builtin themes.
114
114
  #
115
- import sphinx_rtd_theme
115
+ # import sphinx_rtd_theme
116
116
 
117
117
  html_theme = "sphinx_rtd_theme"
118
- html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
118
+ # html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
119
119
 
120
120
  # Add any paths that contain custom static files (such as style sheets) here,
121
121
  # relative to this directory. They are copied after the builtin static files,
@@ -0,0 +1,18 @@
1
+ Simple test
2
+ ------------
3
+
4
+ Show how to send MIDI messages.
5
+
6
+ .. literalinclude:: ../examples/tmidi_simpletest.py
7
+ :caption: examples/tmidi_simpletest.py
8
+ :linenos:
9
+
10
+
11
+ Simple receiver
12
+ ---------------
13
+
14
+ Show to to receive MIDI messages.
15
+
16
+ .. literalinclude:: ../examples/tmidi_simple_receiver.py
17
+ :caption: examples/tmidi_simple_receiver.py
18
+ :linenos:
@@ -0,0 +1,17 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2024 Tod Kurt
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ # This example shows how to receive MIDI NoteOn and NoteOff messages
6
+
7
+ import usb_midi
8
+ import tmidi
9
+
10
+ midi_usb = tmidi.MIDI(midi_in=usb_midi.ports[0], midi_out=usb_midi.ports[1])
11
+
12
+ while True:
13
+ if msg := midi_usb.receive():
14
+ if msg.type == tmidi.NOTE_ON and msg.velocity > 0:
15
+ print("note on: ", msg.note, msg.velocity)
16
+ elif msg.type == tmidi.NOTE_OFF or msg.velocity == 0:
17
+ print("note off:", msg.note, msg.velocity)
@@ -13,7 +13,7 @@ requires = [
13
13
  [project]
14
14
  name = "circuitpython-tmidi"
15
15
  description = "MIDI library for CircuitPython"
16
- version = "1.0.1"
16
+ version = "1.0.3"
17
17
  readme = "README.rst"
18
18
  authors = [
19
19
  {name = "Tod Kurt", email = "tod@todbot.com"}
@@ -32,10 +32,9 @@ Implementation Notes
32
32
 
33
33
  # imports
34
34
 
35
- __version__ = "1.0.1"
35
+ __version__ = "1.0.3"
36
36
  __repo__ = "https://github.com/todbot/CircuitPython_TMIDI.git"
37
37
 
38
-
39
38
  # Portions of this library come from Winterbloom_SmolMIDI:
40
39
  #
41
40
  # The MIT License (MIT)
@@ -60,46 +59,48 @@ __repo__ = "https://github.com/todbot/CircuitPython_TMIDI.git"
60
59
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
61
60
  # THE SOFTWARE.
62
61
 
62
+ from micropython import const
63
+
63
64
  # Message type constants.
64
- NOTE_OFF = 0x80
65
+ NOTE_OFF = const(0x80)
65
66
  """Note Off"""
66
- NOTE_ON = 0x90
67
+ NOTE_ON = const(0x90)
67
68
  """Note On"""
68
- AFTERTOUCH = 0xA0
69
+ AFTERTOUCH = const(0xA0)
69
70
  """Aftertouch"""
70
- CONTROLLER_CHANGE = CC = 0xB0
71
+ CONTROLLER_CHANGE = CC = const(0xB0)
71
72
  """Controller Change"""
72
- PROGRAM_CHANGE = 0xC0
73
+ PROGRAM_CHANGE = const(0xC0)
73
74
  """Program Change"""
74
- CHANNEL_PRESSURE = 0xD0
75
+ CHANNEL_PRESSURE = const(0xD0)
75
76
  """Channel Pressure"""
76
- PITCH_BEND = 0xE0
77
+ PITCH_BEND = const(0xE0)
77
78
  """Pitch Bend"""
78
- SYSTEM_EXCLUSIVE = SYSEX = 0xF0
79
+ SYSTEM_EXCLUSIVE = SYSEX = const(0xF0)
79
80
  """Sysex"""
80
- SONG_POSITION = 0xF2
81
+ SONG_POSITION = const(0xF2)
81
82
  """Song Position"""
82
- SONG_SELECT = 0xF3
83
+ SONG_SELECT = const(0xF3)
83
84
  """Song Select"""
84
- BUS_SELECT = 0xF5
85
+ BUS_SELECT = const(0xF5)
85
86
  """BUS Select"""
86
- TUNE_REQUEST = 0xF6
87
+ TUNE_REQUEST = const(0xF6)
87
88
  """Tune Request"""
88
- SYSEX_END = 0xF7
89
+ SYSEX_END = const(0xF7)
89
90
  """Sysex End"""
90
- CLOCK = 0xF8
91
+ CLOCK = const(0xF8)
91
92
  """Clock"""
92
- TICK = 0xF9
93
+ TICK = const(0xF9)
93
94
  """Tick"""
94
- START = 0xFA
95
+ START = const(0xFA)
95
96
  """Start"""
96
- CONTINUE = 0xFB
97
+ CONTINUE = const(0xFB)
97
98
  """Continue"""
98
- STOP = 0xFC
99
+ STOP = const(0xFC)
99
100
  """Stop"""
100
- ACTIVE_SENSING = 0xFE
101
+ ACTIVE_SENSING = const(0xFE)
101
102
  """Active Sensing"""
102
- SYSTEM_RESET = 0xFF
103
+ SYSTEM_RESET = const(0xFF)
103
104
  """System Reset"""
104
105
 
105
106
  _LEN_0_MESSAGES = set(
@@ -189,11 +190,15 @@ class Message:
189
190
  m = Message(tmidi.NOTE_ON, 0, 60, 127)
190
191
  # create CC 74 with val 63 on ch 4
191
192
  m = Message(tmidi.CC, 3, 74, 63)
193
+ # create a pitch bend full up on ch 1
194
+ m = Message(tmidi.PITCH_BEND, 0, 8191)
192
195
  """
193
196
  self.type = mtype
194
197
  self.channel = channel
195
198
  self.data0 = data0
196
199
  self.data1 = data1
200
+ if mtype == PITCH_BEND and data1 == 0:
201
+ self.pitch_bend = data0
197
202
 
198
203
  def __bytes__(self):
199
204
  status_byte = self.type
@@ -246,6 +251,7 @@ class Message:
246
251
 
247
252
  @pitch_bend.setter
248
253
  def pitch_bend(self, pbval):
254
+ pbval += 8192
249
255
  self.data0 = pbval & 0x7F
250
256
  self.data1 = pbval >> 7
251
257
 
@@ -1,8 +0,0 @@
1
- Simple test
2
- ------------
3
-
4
- Ensure your device works with this simple test.
5
-
6
- .. literalinclude:: ../examples/tmidi_simpletest.py
7
- :caption: examples/tmidi_simpletest.py
8
- :linenos: