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 controller 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. (RaisesOSErrorif 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:
FADERBUTTONENCODER
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pmpcontrol-0.0.1.tar.gz.
File metadata
- Download URL: pmpcontrol-0.0.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01ae393b650772a86152d8eca0e1b1076284a0b55f0d38318fae7a2f9db69aca
|
|
| MD5 |
7e55de5cf799cc18397ed455b946e1ad
|
|
| BLAKE2b-256 |
63fabd5cb4a4b29b03ff053d794cc5a8b32a5c4b3877f7d93d3b0fe396b3ddd7
|
File details
Details for the file pmpcontrol-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pmpcontrol-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd47430da8c8fa559ef527876ce30e8aaab49df5367c94c5f39a4a286ab0192b
|
|
| MD5 |
8943c0d78ea4757e03345a6dc9db7143
|
|
| BLAKE2b-256 |
42e7a3c4af75f0d7300b9308b63f2d433726877e88f2c4dd05598b5aab948086
|