Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: todbot/CircuitPython_TMIDI
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: todbot/CircuitPython_TMIDI
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: big_fixes
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 15 commits
  • 15 files changed
  • 1 contributor

Commits on May 13, 2026

  1. update pre-commit

    todbot committed May 13, 2026
    Configuration menu
    Copy the full SHA
    44e2d6a View commit details
    Browse the repository at this point in the history
  2. small readme fix

    todbot committed May 13, 2026
    Configuration menu
    Copy the full SHA
    b51f2c8 View commit details
    Browse the repository at this point in the history
  3. Optimize receive() for CircuitPython, fix three correctness bugs

    Performance (hot path in receive()):
    - Switch port reads from read(1) — which allocates a new bytes object on
      every call — to `readinto(self._read_buf)`, reusing the bytearray already
      allocated in `__init__` but previously unused
    - Cache `self._in_port` and `self._read_buf` as locals to avoid repeated dict
      lookups on self inside the tight loop
    - Replace two `_LEN_*_MESSAGES` set membership checks with a single
      `_MSG_DATA_LEN.get()` dict lookup to determine data byte count
    - Inline data-byte reads and corruption checks; remove the tuple allocation
      that the old validation loop created on every call
    - Use a module-level `_msg_buf` scratch bytearray in `__bytes__()` instead of
       `bytes([...])`, avoiding a list allocation per serialization
    
     Correctness:
     - Fix SysEx desync: SYSEX was in `_LEN_0_MESSAGES` so `receive()` returned
       immediately after the 0xF0 status byte, leaving the variable-length
       payload in the port buffer and causing all subsequent receive() calls to
       fail with error_count increments. Now the parser consumes bytes until
       0xF7 before returning Message(SYSEX).
    - Fix channel-0 silent drop: `send(msg, channel=0)` was a no-op because
      `if channel:` is falsy for 0. Changed to `if channel is not None:`.
    - Fix pitch bend full-down corruption: `Message.__init__` triggered the
      user-API shortcut (treating data0 as a full pitchbend value) whenever
      data1==0, which corrupted wire bytes [0xE0, 0x00, 0x00] (-8192) into
      [0xE0, 0x00, 0x40] (center 0). The condition now also requires data0
      to be outside the valid raw-MIDI-byte range (0–127).
    todbot committed May 13, 2026
    Configuration menu
    Copy the full SHA
    871d43f View commit details
    Browse the repository at this point in the history
  4. test device attempt

    examples/tmidi_test_device.py (CircuitPython, copy to device as code.py):
    - Echo loop — receives any MIDI message and sends it back, except SysEx which is consumed silently
    - LED blinks on each message; prints each message to the REPL with running error count
    - USE_USB_MIDI = True (default) for USB MIDI; set to False + add usb_cdc.enable() in boot.py for the serial path
    
    examples/tmidi_test_host.py (CPython):
    - --usb-midi mode uses mido + python-rtmidi; auto-detects "circuit/pico" in port names, or --port NAME to specify
    - --serial PORT mode uses pyserial; sends raw MIDI bytes and parses the echo stream
    - 9 tests: NOTE_ON/OFF, CC, Program Change, pitch bend (center / full-up / full-down), Clock, and the SysEx desync test
    - Pass/fail per test with elapsed ms; exits with code 0 on all-pass, 1 on any failure
    todbot committed May 13, 2026
    Configuration menu
    Copy the full SHA
    1352b96 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ed36aea View commit details
    Browse the repository at this point in the history

Commits on May 14, 2026

  1. fix sysex hanging receive

    todbot committed May 14, 2026
    Configuration menu
    Copy the full SHA
    2f786dc View commit details
    Browse the repository at this point in the history
  2. add sysex examples

    todbot committed May 14, 2026
    Configuration menu
    Copy the full SHA
    d9a9702 View commit details
    Browse the repository at this point in the history
  3. add synthetic benchmark test

    todbot committed May 14, 2026
    Configuration menu
    Copy the full SHA
    6b4f202 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9566c0b View commit details
    Browse the repository at this point in the history
  5. update readme

    todbot committed May 14, 2026
    Configuration menu
    Copy the full SHA
    07811d0 View commit details
    Browse the repository at this point in the history
  6. improve synthetic test to more accurately reflect what a real project…

    … would need for MIDI messages
    todbot committed May 14, 2026
    Configuration menu
    Copy the full SHA
    6e3431d View commit details
    Browse the repository at this point in the history
  7. cleanup simple arp example

    todbot committed May 14, 2026
    Configuration menu
    Copy the full SHA
    00238d7 View commit details
    Browse the repository at this point in the history
  8. add sysex support

    todbot committed May 14, 2026
    Configuration menu
    Copy the full SHA
    274ab0a View commit details
    Browse the repository at this point in the history
  9. formatting fixes

    todbot committed May 14, 2026
    Configuration menu
    Copy the full SHA
    f116e34 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2026

  1. Configuration menu
    Copy the full SHA
    6c55863 View commit details
    Browse the repository at this point in the history
Loading