|
20 | 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21 | 21 | # THE SOFTWARE. |
22 | 22 | """ |
23 | | -`adafruit_midi` |
| 23 | +`adafruit_midi.midi_message.MIDIMessage` |
24 | 24 | ================================================================================ |
25 | 25 |
|
26 | | -A CircuitPython helper for encoding/decoding MIDI packets over a MIDI or UART connection. |
| 26 | +An abstract class for objects which represent MIDI messages (events). |
| 27 | +When individual messages are imported they register themselves with |
| 28 | +:func:register_message_type which makes them recognised |
| 29 | +by the parser, :func:from_message_bytes. |
| 30 | +
|
| 31 | +Large messages like :class:SystemExclusive can only be parsed if they fit |
| 32 | +within the input buffer in :class:MIDI. |
27 | 33 |
|
28 | 34 |
|
29 | 35 | * Author(s): Kevin J. Walters |
30 | 36 |
|
31 | 37 | Implementation Notes |
32 | 38 | -------------------- |
33 | 39 |
|
34 | | -**Hardware:** |
35 | | -
|
36 | | -
|
37 | | -
|
38 | | -**Software and Dependencies:** |
39 | | -
|
40 | | -* Adafruit CircuitPython firmware for the supported boards: |
41 | | - https://github.com/adafruit/circuitpython/releases |
42 | | -
|
43 | 40 | """ |
44 | 41 |
|
45 | 42 | __version__ = "0.0.0-auto.0" |
@@ -97,16 +94,19 @@ def note_parser(note): |
97 | 94 |
|
98 | 95 | class MIDIMessage: |
99 | 96 | """ |
100 | | - A MIDI message: |
101 | | - - _STATUS - extracted from Status byte with channel replaced by 0s |
102 | | - (high bit always set). |
103 | | - - _STATUSMASK - mask used to compared a status byte with _STATUS value |
104 | | - - LENGTH - length for a fixed size message including status |
105 | | - or -1 for variable length. |
106 | | - - CHANNELMASK - mask use to apply a (wire protocol) channel number. |
107 | | - - ENDSTATUS - the EOM status byte, only set for variable length. |
108 | | -
|
109 | | - This is an abstract class. |
| 97 | + The parent class for MIDI messages. |
| 98 | +
|
| 99 | + Class variables: |
| 100 | +
|
| 101 | + * ``_STATUS`` - extracted from status byte with channel replaced by 0s |
| 102 | + (high bit is always set by convention). |
| 103 | + * ``_STATUSMASK`` - mask used to compared a status byte with ``_STATUS`` value. |
| 104 | + * ``LENGTH`` - length for a fixed size message *including* status |
| 105 | + or -1 for variable length. |
| 106 | + * ``CHANNELMASK`` - mask used to apply a (wire protocol) channel number. |
| 107 | + * ``ENDSTATUS`` - the end of message status byte, only set for variable length. |
| 108 | +
|
| 109 | + This is an *abstract* class. |
110 | 110 | """ |
111 | 111 | _STATUS = None |
112 | 112 | _STATUSMASK = None |
@@ -277,18 +277,21 @@ def from_message_bytes(cls, midibytes, channel_in): |
277 | 277 | return (msg, msgendidxplusone, skipped, channel) |
278 | 278 |
|
279 | 279 | # channel value present to keep interface uniform but unused |
| 280 | + # A default method for constructing wire messages with no data. |
| 281 | + # Returns a (mutable) bytearray with just the status code in. |
280 | 282 | # pylint: disable=unused-argument |
281 | 283 | def as_bytes(self, channel=None): |
282 | | - """A default method for constructing wire messages with no data. |
283 | | - Returns a (mutable) bytearray with just status code in.""" |
| 284 | + """Return the ``bytearray`` wire protocol representation of the object.""" |
284 | 285 | return bytearray([self._STATUS]) |
285 | 286 |
|
286 | 287 | # databytes value present to keep interface uniform but unused |
| 288 | + # A default method for constructing message objects with no data. |
| 289 | + # Returns the new object. |
287 | 290 | # pylint: disable=unused-argument |
288 | 291 | @classmethod |
289 | 292 | def from_bytes(cls, databytes): |
290 | | - """A default method for constructing message objects with no data. |
291 | | - Returns the new object.""" |
| 293 | + """Creates an object from the byte stream of the wire protocol |
| 294 | + (not including the first status byte).""" |
292 | 295 | return cls() |
293 | 296 |
|
294 | 297 |
|
|
0 commit comments