6fc0a84dfe
ControlSurface exposes song and application as properties, not callable methods. Replace manager.song() and manager.application() with the correct attribute access throughout handler, application, browser, and view modules. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
"""Handles /live/application/* OSC addresses."""
|
|
import logging
|
|
from typing import Optional
|
|
from .handler import AbletonOSCHandler
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ApplicationHandler(AbletonOSCHandler):
|
|
def init_api(self) -> None:
|
|
self.clear_listeners()
|
|
self._add("/live/application/get/version", self._get_version)
|
|
self._add("/live/application/get/average_process_usage",
|
|
self._get_average_process_usage)
|
|
self._add("/live/application/get/peak_process_usage",
|
|
self._get_peak_process_usage)
|
|
|
|
def _app(self):
|
|
try:
|
|
return self.manager.application
|
|
except Exception:
|
|
return None
|
|
|
|
def _get_version(self, params: tuple) -> Optional[tuple]:
|
|
app = self._app()
|
|
if app:
|
|
try:
|
|
major, minor = app.get_major_version(), app.get_minor_version()
|
|
build = app.get_bugfix_version()
|
|
return (major, minor, build)
|
|
except Exception as e:
|
|
logger.warning("get version: %s", e)
|
|
return None
|
|
|
|
def _get_average_process_usage(self, params: tuple) -> Optional[tuple]:
|
|
app = self._app()
|
|
if app:
|
|
try:
|
|
return (float(app.average_process_usage),)
|
|
except Exception as e:
|
|
logger.warning("get avg process usage: %s", e)
|
|
return None
|
|
|
|
def _get_peak_process_usage(self, params: tuple) -> Optional[tuple]:
|
|
app = self._app()
|
|
if app:
|
|
try:
|
|
return (float(app.peak_process_usage),)
|
|
except Exception as e:
|
|
logger.warning("get peak process usage: %s", e)
|
|
return None
|