Skip to main content

A Python interface for interacting with the iCON Platform M+ MIDI control surface.

Project description

Platform M+ MIDI Controller

This Python package provides an interface for interacting with the iCON Platform M+ MIDI control surface.

Features

  • Get and set fader positions
  • Get and set button light states
  • Add and remove event listeners for encoder, fader and button events
  • Sync fader positions with user movement, preventing them from dropping

Installation

To install the package, use pip:

pip install pmpcontrol

Example Usage

from pmpcontrol import PMPController, PMPEvent

# Initialize the controller
controller = PMPController(sync_faders=True)

# Connect to the device
try:
    controller.connect()
    print("Connected to Platform M+")
except OSError as error:
    print(error)

# Define event handler to flash buttons when pressed
def on_button_press(button_number, is_pressed, state):
    controller.set_button(button_number, not state)
    print(f"Button {button_number} {'pressed' if is_pressed else 'released'}")

# Add event listener
controller.add_event_listener(PMPEvent.BUTTON, on_button_press)

# Set a fader position
controller.set_fader(0, 0.5)  # Set fader 0 to 50%

# Keep the script running to handle events
try:
    print("Press Ctrl+C to exit.")
    while True:
        pass
except KeyboardInterrupt:
    print("Exiting...")
finally:
    # Disconnect when done
    controller.reset()
    controller.disconnect()

API Reference

PMPController

The main controller class:

  • __init__(sync_faders: bool = False): Initialize the controller.
  • connect() -> Tuple[int, int]: Connect to the Platform M+ device. (Raises OSError if Platform M+ device not found)
  • disconnect(): Disconnect from the device.
  • set_fader(fader_number: int, normalized_position: float): Set a fader position.
  • get_fader(fader_number: int) -> float: Get a fader position.
  • set_button(button_number: int, state: bool): Set a button state.
  • get_button(button_number: int) -> bool: Get a button state.
  • reset(): Reset all faders and buttons to their default states.
  • set_fader_sync(sync_faders: bool): Enable or disable fader syncing.
  • add_event_listener(event_type: PMPEvent, callback: Callable): Add an event listener callback.
  • remove_event_listener(event_type: PMPEvent, callback: Callable): Remove an event listener callback.

PMPEvent

An enum representing different types of events:

  • FADER
  • BUTTON
  • ENCODER

Event Listener Callbacks

  • Fader: callback(fader_number: int, normalized_value: float)
  • Button: callbacks(button_number: int, is_pressed: bool, button_state: bool)
  • Encoder: callback(encoder_number: int, value: int)

The fader callback's normalized_value argument is a float between 0 and 1 representing position.
The encoder callback's value is a number from 1 to 7 when turned right, and 65 to 71 when turned left, with a higher value representing a faster speed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pmpcontrol-0.0.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pmpcontrol-0.0.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pmpcontrol-0.0.2.tar.gz.

File metadata

  • Download URL: pmpcontrol-0.0.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pmpcontrol-0.0.2.tar.gz
Algorithm Hash digest
SHA256 287b008c4fd70f42f00c25a6e7cf45a7ce4fe1c46b57914876e5a7e738f1a0b8
MD5 9ff25311a4ed173f3583f703387db999
BLAKE2b-256 7dc89c0d9923d407ec300c37f55ac56b736470cc9f1aeb2411cd4a132a127b30

See more details on using hashes here.

File details

Details for the file pmpcontrol-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pmpcontrol-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pmpcontrol-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 de0b3f8ba0de23266789c3de51175eeace4630f4b1053fa364536f1722732495
MD5 7e6d70551ff6365d6811e7fc9007b01e
BLAKE2b-256 57b334c327b89dd396deb4cf3e1086dc33da3b021b3ebf87bd752101bf79cbd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page