hydra-midi icon indicating copy to clipboard operation
hydra-midi copied to clipboard

chore: add pitch bend message

Open Magicking opened this issue 4 months ago • 0 comments

Status

To test, the TouchDAW demo application in workshop mode is used to send MIDI messages via usb-midi.

There are few problems with the onBend and wildcard (investigating issue) and the PR lacks documentation examples

Hydra test bench

Description

This pull request adds support for MIDI pitch bend events to the Hydra MIDI API. The main changes include introducing new state management for pitch bend values and events, exposing pitch bend utilities and event handlers throughout the API, and updating transforms to allow easy access to pitch bend data. These updates make it possible to read and react to pitch bend messages in a way consistent with other MIDI controls in the system.

Pitch Bend Support

  • Added bend and _bend functions in src/hydra-api/bend.ts to retrieve and chain pitch bend values, along with a utility to generate a pitch bend ID.
  • Introduced onBend event handler in src/hydra-api/onBend.ts for registering callbacks on pitch bend events.
  • Updated exports in src/hydra-api/index.ts to include pitch bend utilities and event handlers.

State Management

  • Added bendValues and bendEvents maps to src/state.ts to store pitch bend values and event handlers, including session storage persistence and monkey-patching for auto-save. [1] [2] [3]
  • Modified src/midiAccess.ts to handle incoming pitch bend messages, normalize values, update state, and trigger registered event handlers. [1] [2]

Transforms and API Exposure

  • Updated channel and input transforms to provide bend and onBend methods for accessing pitch bend data and registering event handlers per channel/input. [1] [2] [3] [4] [5] [6] [7]
  • Exposed bend and _bend functions in the global window object for use in scripts. [1] [2]

Type Definitions

  • Added BendId type and BendEventContext interface to src/types.ts for strong typing of pitch bend IDs and event contexts. [1] [2]

Magicking avatar Aug 15 '25 16:08 Magicking