Skip to content

Commit 1811478

Browse files
author
Kevin J Walters
committed
Adding documentation to each of the MIDI message classes.
Adding use of note_parser() in constuctor for PolyphonicKeyPressure. #3
1 parent 0ae13ef commit 1811478

11 files changed

Lines changed: 61 additions & 2 deletions

adafruit_midi/channel_pressure.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949

5050

5151
class ChannelPressure(MIDIMessage):
52+
"""Channel Pressure MIDI message.
53+
54+
:param int pressure: The pressure, 0-127.
55+
"""
56+
5257
_STATUS = 0xd0
5358
_STATUSMASK = 0xf0
5459
LENGTH = 2

adafruit_midi/control_change.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949

5050

5151
class ControlChange(MIDIMessage):
52+
"""Control Change MIDI message.
53+
54+
:param int control: The control number, 0-127.
55+
:param int value: The 7bit value of the control, 0-127.
56+
57+
"""
58+
5259
_STATUS = 0xb0
5360
_STATUSMASK = 0xf0
5461
LENGTH = 3

adafruit_midi/note_off.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949

5050

5151
class NoteOff(MIDIMessage):
52+
"""Note Off Change MIDI message.
53+
54+
:param note: The note (key) number either as an int (0-127) or a str which is parsed, e.g. "C4" (middle C) is 60, "A4" is 69.
55+
:param int velocity: The release velocity, 0-127.
56+
57+
"""
58+
5259
_STATUS = 0x80
5360
_STATUSMASK = 0xf0
5461
LENGTH = 3

adafruit_midi/note_on.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949

5050

5151
class NoteOn(MIDIMessage):
52+
"""Note On Change MIDI message.
53+
54+
:param note: The note (key) number either as an int (0-127) or a str which is parsed, e.g. "C4" (middle C) is 60, "A4" is 69.
55+
:param int velocity: The strike velocity, 0-127, 0 is equivalent to a Note Off.
56+
"""
57+
5258
_STATUS = 0x90
5359
_STATUSMASK = 0xf0
5460
LENGTH = 3

adafruit_midi/pitch_bend_change.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949

5050

5151
class PitchBendChange(MIDIMessage):
52+
"""Pitch Bend Change MIDI message.
53+
54+
:param int pitch_bend: A 14bit unsigned int representing the degree of bend from 0 through 8192 (midpoint, no bend) to 16383.
55+
"""
56+
5257
_STATUS = 0xe0
5358
_STATUSMASK = 0xf0
5459
LENGTH = 3

adafruit_midi/polyphonic_key_pressure.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,26 @@
4242
4343
"""
4444

45-
from .midi_message import MIDIMessage
45+
from .midi_message import MIDIMessage, note_parser
4646

4747
__version__ = "0.0.0-auto.0"
4848
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MIDI.git"
4949

5050

5151
class PolyphonicKeyPressure(MIDIMessage):
52+
"""Polyphonic Key Pressure MIDI message.
53+
54+
:param note: The note (key) number either as an int (0-127) or a str which is parsed, e.g. "C4" (middle C) is 60, "A4" is 69.
55+
:param int pressure: The pressure, 0-127.
56+
"""
57+
5258
_STATUS = 0xa0
5359
_STATUSMASK = 0xf0
5460
LENGTH = 3
5561
CHANNELMASK = 0x0f
5662

5763
def __init__(self, note, pressure):
58-
self.note = note
64+
self.note = note_parser(note)
5965
self.pressure = pressure
6066
if not 0 <= self.note <= 127 or not 0 <= self.pressure <= 127:
6167
raise ValueError("Out of range")

adafruit_midi/program_change.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949

5050

5151
class ProgramChange(MIDIMessage):
52+
"""Program Change MIDI message.
53+
54+
:param int patch: The new program/patch number to use, 0-127.
55+
"""
56+
5257
_STATUS = 0xc0
5358
_STATUSMASK = 0xf0
5459
LENGTH = 2

adafruit_midi/start.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949

5050

5151
class Start(MIDIMessage):
52+
"""Start MIDI message.
53+
"""
54+
5255
_STATUS = 0xfa
5356
_STATUSMASK = 0xff
5457
LENGTH = 1

adafruit_midi/stop.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949

5050

5151
class Stop(MIDIMessage):
52+
"""Stop MIDI message.
53+
"""
5254
_STATUS = 0xfc
5355
_STATUSMASK = 0xff
5456
LENGTH = 1

adafruit_midi/system_exclusive.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949

5050

5151
class SystemExclusive(MIDIMessage):
52+
"""System Exclusive MIDI message.
53+
54+
:param list manufacturer_id: The single byte or three byte manufacturer's id as a list or bytearray of numbers between 0-127.
55+
:param list data: The 7bit data as a list or bytearray of numbers between 0-127.
56+
"""
57+
5258
_STATUS = 0xf0
5359
_STATUSMASK = 0xff
5460
LENGTH = -1

0 commit comments

Comments
 (0)