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.
  • is_connected -> bool: Returns True if the device is connected
  • set_fader(fader_number: int, normalized_position: float): Set a fader position. (Raises OSError if Platform M+ device not found)
  • get_fader(fader_number: int) -> float: Get a fader position.
  • set_button(button_number: int, state: bool): Set a button state. (Raises OSError if Platform M+ device not found)
  • get_button(button_number: int) -> bool: Get a button state.
  • reset(): Reset all faders and buttons to their default states. (Raises OSError if Platform M+ device not found)
  • 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.3.tar.gz (6.5 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.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pmpcontrol-0.0.3.tar.gz
Algorithm Hash digest
SHA256 890ea8686809ca150f1ccdf95967ab0643ab7494fecc1d553c27404f2d683662
MD5 e36cae65de05eace8af8d00dfcdfd6b8
BLAKE2b-256 54937127e0534e9e3398f68b5a861682e056d0eace7d41be59f069276101bc03

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pmpcontrol-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4f894a3f91a843a87f6fdd24b84551ee54c3d3ee0959ee9ca660c785ece69361
MD5 adc9a9d144b82ef3cb6fc153cbe548bc
BLAKE2b-256 78e8e432308a89a28e8baccb8e74a63c6dce474dab4c71ed14a79a36350c16e4

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