Metadata-Version: 2.1
Name: pymmcore-midi
Version: 0.1.0
Summary: Midi control for microscopes using pymmcore
Project-URL: homepage, https://github.com/pymmcore-plus/pymmcore-midi
Project-URL: repository, https://github.com/pymmcore-plus/pymmcore-midi
Author-email: Talley Lambert <talley.lambert@gmail.com>
License: BSD-3-Clause
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: mido[ports-rtmidi]
Requires-Dist: psygnal>=0.9.0
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: ipython; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pdbpp; extra == 'dev'
Requires-Dist: rich; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: test
Requires-Dist: pymmcore-plus; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pyyaml; extra == 'test'
Description-Content-Type: text/markdown

# pymmcore-midi

[![License](https://img.shields.io/pypi/l/pymmcore-midi.svg?color=green)](https://github.com/pymmcore-plus/pymmcore-midi/raw/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/pymmcore-midi.svg?color=green)](https://pypi.org/project/pymmcore-midi)
[![Python
Version](https://img.shields.io/pypi/pyversions/pymmcore-midi.svg?color=green)](https://python.org)
[![CI](https://github.com/pymmcore-plus/pymmcore-midi/actions/workflows/ci.yml/badge.svg)](https://github.com/pymmcore-plus/pymmcore-midi/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/pymmcore-plus/pymmcore-midi/branch/main/graph/badge.svg)](https://codecov.io/gh/pymmcore-plus/pymmcore-midi)

MIDI Device control for microscopes using pymmcore

## Installation

```bash
pip install pymmcore-midi
```

## Usage

Create a `pymmcore_midi.DeviceMap` object (can be done from a YAML/JSON file),
then connect it to a [pymmcore-plus
`CMMCorePlus`](https://pymmcore-plus.github.io/pymmcore-plus/api/cmmcoreplus/)
object.

```yaml
device_name: X-TOUCH MINI
mappings:
  - [button, 8, Camera, AllowMultiROI]
  - [button, 9, Camera, Binning]
  - [knob, 2, Camera, Gain]
  - [knob, 9, Camera, CCDTemperature]
  # can also use this form
  - message_type: control_change
    control_id: 1
    device_label: Camera
    property_name: Exposure
  - message_type: button
    control_id: 10
    core_method: snap
  - message_type: knob
    control_id: 17
    core_method: setAutoFocusOffset
```

```python
core = CMMCorePlus()
core.loadSystemConfiguration()

dev_map = DeviceMap.from_file(f)
dev_map.connect_to_core(core)
```

Now when you move a knob or press a button on your MIDI device, the
corresponding property/method will be updated/called on the `CMMCorePlus`
object. :tada:

## Debugging/Development

Use the environment variable `PYMMCORE_MIDI_DEBUG=1` to print out the MIDI
messages that are being received from your device. (This is useful to determine
the appropriate message type and control ID for your device map.)
