livepilot 1.26.2 → 1.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -0
- package/README.md +34 -14
- package/bin/livepilot.js +4 -2
- package/installer/install.js +21 -12
- package/livepilot/.Codex-plugin/plugin.json +2 -2
- package/livepilot/.claude-plugin/plugin.json +2 -2
- package/livepilot/skills/livepilot-core/SKILL.md +12 -12
- package/livepilot/skills/livepilot-core/references/device-knowledge/effects-space.md +2 -1
- package/livepilot/skills/livepilot-core/references/overview.md +6 -4
- package/livepilot/skills/livepilot-core/references/sound-design.md +5 -2
- package/livepilot/skills/livepilot-creative-director/SKILL.md +36 -0
- package/livepilot/skills/livepilot-creative-director/references/move-family-diversity-rule.md +1 -1
- package/livepilot/skills/livepilot-evaluation/references/capability-modes.md +15 -9
- package/livepilot/skills/livepilot-release/SKILL.md +7 -5
- package/m4l_device/LivePilot_Analyzer.amxd +0 -0
- package/m4l_device/livepilot_bridge.js +1 -1
- package/mcp_server/__init__.py +1 -1
- package/mcp_server/atlas/__init__.py +20 -1
- package/mcp_server/atlas/tools.py +83 -22
- package/mcp_server/composer/full/apply.py +9 -0
- package/mcp_server/composer/full/layer_planner.py +16 -6
- package/mcp_server/creative_constraints/engine.py +46 -0
- package/mcp_server/experiment/engine.py +10 -3
- package/mcp_server/grader/client.py +30 -2
- package/mcp_server/grader/tools.py +8 -2
- package/mcp_server/hook_hunter/analyzer.py +15 -2
- package/mcp_server/m4l_bridge.py +19 -21
- package/mcp_server/memory/taste_graph.py +16 -0
- package/mcp_server/memory/technique_store.py +23 -3
- package/mcp_server/mix_engine/state_builder.py +4 -2
- package/mcp_server/musical_intelligence/detectors.py +11 -2
- package/mcp_server/musical_intelligence/tools.py +15 -2
- package/mcp_server/preview_studio/engine.py +30 -1
- package/mcp_server/project_brain/tools.py +56 -52
- package/mcp_server/reference_engine/tools.py +22 -2
- package/mcp_server/runtime/capability_probe.py +1 -1
- package/mcp_server/runtime/capability_state.py +66 -9
- package/mcp_server/runtime/live_version.py +45 -8
- package/mcp_server/runtime/safety_kernel.py +11 -0
- package/mcp_server/runtime/session_kernel.py +7 -0
- package/mcp_server/runtime/tools.py +324 -22
- package/mcp_server/sample_engine/critics.py +7 -3
- package/mcp_server/sample_engine/slice_workflow.py +3 -2
- package/mcp_server/sample_engine/tools.py +53 -21
- package/mcp_server/song_brain/builder.py +17 -1
- package/mcp_server/sound_design/tools.py +1 -1
- package/mcp_server/splice_client/http_bridge.py +43 -1
- package/mcp_server/splice_client/models.py +7 -3
- package/mcp_server/synthesis_brain/adapters/analog.py +13 -1
- package/mcp_server/synthesis_brain/adapters/operator.py +5 -2
- package/mcp_server/synthesis_brain/adapters/wavetable.py +4 -4
- package/mcp_server/tools/_composition_engine/models.py +6 -0
- package/mcp_server/tools/_composition_engine/sections.py +4 -0
- package/mcp_server/tools/analyzer.py +38 -1
- package/mcp_server/tools/clips.py +5 -4
- package/mcp_server/tools/composition.py +5 -1
- package/mcp_server/tools/midi_io.py +40 -1
- package/mcp_server/tools/transport.py +1 -1
- package/mcp_server/user_corpus/plugin_engine/detector.py +66 -11
- package/mcp_server/user_corpus/runner.py +7 -1
- package/mcp_server/user_corpus/scanners/amxd.py +24 -13
- package/mcp_server/user_corpus/tools.py +45 -9
- package/mcp_server/wonder_mode/tools.py +66 -27
- package/package.json +2 -2
- package/remote_script/LivePilot/__init__.py +1 -1
- package/remote_script/LivePilot/server.py +23 -3
- package/remote_script/LivePilot/version_detect.py +3 -0
- package/requirements.txt +4 -4
- package/server.json +3 -3
|
@@ -45,6 +45,7 @@ import logging
|
|
|
45
45
|
import os
|
|
46
46
|
import ssl
|
|
47
47
|
import urllib.error
|
|
48
|
+
import urllib.parse
|
|
48
49
|
import urllib.request
|
|
49
50
|
from dataclasses import dataclass, field
|
|
50
51
|
from typing import Any, Optional
|
|
@@ -89,6 +90,10 @@ class SpliceHTTPConfig:
|
|
|
89
90
|
user_agent: str = "LivePilot/1.16 (+splice-http-bridge)"
|
|
90
91
|
timeout_sec: float = 30.0
|
|
91
92
|
max_retries: int = 2
|
|
93
|
+
# Opt-in escape hatch: when True, the bearer-token host guard in
|
|
94
|
+
# SpliceHTTPBridge._request is bypassed so a custom (non-splice.com)
|
|
95
|
+
# base_url may receive the session token. Defaults off.
|
|
96
|
+
allow_unverified_endpoints: bool = False
|
|
92
97
|
# Whether any of the above values came from user config (file or env)
|
|
93
98
|
# rather than the built-in defaults. Used by `is_user_configured`.
|
|
94
99
|
_user_configured: bool = False
|
|
@@ -135,6 +140,7 @@ class SpliceHTTPConfig:
|
|
|
135
140
|
"splice.json: %s must be an integer", key,
|
|
136
141
|
)
|
|
137
142
|
if data.get("allow_unverified_endpoints"):
|
|
143
|
+
instance.allow_unverified_endpoints = True
|
|
138
144
|
loaded_from_file = True
|
|
139
145
|
except (OSError, json.JSONDecodeError) as exc:
|
|
140
146
|
logger.warning(
|
|
@@ -161,6 +167,9 @@ class SpliceHTTPConfig:
|
|
|
161
167
|
"Env %s has invalid value: %s", env_name, exc,
|
|
162
168
|
)
|
|
163
169
|
|
|
170
|
+
if os.environ.get("SPLICE_ALLOW_UNVERIFIED_ENDPOINTS") == "1":
|
|
171
|
+
instance.allow_unverified_endpoints = True
|
|
172
|
+
|
|
164
173
|
instance._user_configured = (
|
|
165
174
|
loaded_from_file
|
|
166
175
|
or env_configured
|
|
@@ -406,6 +415,23 @@ class SpliceHTTPError(Exception):
|
|
|
406
415
|
}
|
|
407
416
|
|
|
408
417
|
|
|
418
|
+
def _is_trusted_splice_host(url: str) -> bool:
|
|
419
|
+
"""True only for HTTPS URLs on a splice.com-owned host.
|
|
420
|
+
|
|
421
|
+
Gates attaching the rotating session bearer token: a poisoned base_url
|
|
422
|
+
(custom config file or SPLICE_API_BASE_URL env) must not be able to
|
|
423
|
+
exfiltrate the token to an attacker-controlled endpoint.
|
|
424
|
+
"""
|
|
425
|
+
try:
|
|
426
|
+
parsed = urllib.parse.urlparse(url)
|
|
427
|
+
except (ValueError, AttributeError):
|
|
428
|
+
return False
|
|
429
|
+
if parsed.scheme != "https":
|
|
430
|
+
return False
|
|
431
|
+
host = (parsed.hostname or "").lower()
|
|
432
|
+
return host == "splice.com" or host.endswith(".splice.com")
|
|
433
|
+
|
|
434
|
+
|
|
409
435
|
class SpliceHTTPBridge:
|
|
410
436
|
"""Low-level HTTPS client for Splice cloud APIs.
|
|
411
437
|
|
|
@@ -442,10 +468,26 @@ class SpliceHTTPBridge:
|
|
|
442
468
|
|
|
443
469
|
url = self.config.base_url.rstrip("/") + path
|
|
444
470
|
if query:
|
|
445
|
-
import urllib.parse
|
|
446
471
|
qs = urllib.parse.urlencode(query)
|
|
447
472
|
url = f"{url}?{qs}"
|
|
448
473
|
|
|
474
|
+
# Token-exfil guard: only attach the Splice session bearer when the
|
|
475
|
+
# destination is a splice.com-owned HTTPS host. A poisoned base_url
|
|
476
|
+
# (custom config/env) otherwise leaks the rotating session token to an
|
|
477
|
+
# attacker-controlled endpoint. Explicit opt-in via
|
|
478
|
+
# allow_unverified_endpoints / SPLICE_ALLOW_UNVERIFIED_ENDPOINTS=1.
|
|
479
|
+
if not _is_trusted_splice_host(url) and not self.config.allow_unverified_endpoints:
|
|
480
|
+
raise SpliceHTTPError(
|
|
481
|
+
code="UNTRUSTED_ENDPOINT",
|
|
482
|
+
message=(
|
|
483
|
+
f"Refusing to send the Splice session token to non-Splice host "
|
|
484
|
+
f"'{self.config.base_url}'. Set allow_unverified_endpoints in "
|
|
485
|
+
f"~/.livepilot/splice.json (or SPLICE_ALLOW_UNVERIFIED_ENDPOINTS=1) "
|
|
486
|
+
f"to override."
|
|
487
|
+
),
|
|
488
|
+
endpoint=path,
|
|
489
|
+
)
|
|
490
|
+
|
|
449
491
|
data_bytes = None
|
|
450
492
|
headers = {
|
|
451
493
|
"Authorization": f"Bearer {token}",
|
|
@@ -185,10 +185,14 @@ class SpliceSample:
|
|
|
185
185
|
def is_free(self) -> bool:
|
|
186
186
|
"""True iff this sample costs no credits under any plan.
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
`IsPremium` is Splice's authoritative free flag and is always
|
|
189
|
+
populated in the proto. `Price` is NOT reliable: proto3 ints
|
|
190
|
+
default to 0 when the server omits the field, so OR-ing in
|
|
191
|
+
`price == 0` would misclassify premium samples (whose Price is
|
|
192
|
+
unset/zero) as free and bypass ALL credit/quota gating. Trust
|
|
193
|
+
only `IsPremium`.
|
|
190
194
|
"""
|
|
191
|
-
return
|
|
195
|
+
return not self.is_premium
|
|
192
196
|
|
|
193
197
|
def to_dict(self) -> dict:
|
|
194
198
|
return {
|
|
@@ -9,9 +9,12 @@ detune/unison variants and dual-filter variants.
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
import hashlib
|
|
12
|
+
import logging
|
|
12
13
|
from typing import Optional
|
|
13
14
|
|
|
14
15
|
from ...branches import BranchSeed, freeform_seed
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
15
18
|
from ..models import (
|
|
16
19
|
SynthProfile,
|
|
17
20
|
TimbralFingerprint,
|
|
@@ -115,7 +118,16 @@ class AnalogAdapter:
|
|
|
115
118
|
try:
|
|
116
119
|
maybe = strategy_fn(profile, target, kernel, adapter=self)
|
|
117
120
|
except Exception:
|
|
118
|
-
# Never let one strategy's crash kill the rest
|
|
121
|
+
# Never let one strategy's crash kill the rest, but make the
|
|
122
|
+
# swallowed failure observable instead of silently degrading
|
|
123
|
+
# the branch set.
|
|
124
|
+
logger.warning(
|
|
125
|
+
"Analog strategy %s crashed on track %s device %s; skipping",
|
|
126
|
+
getattr(strategy_fn, "__name__", strategy_fn),
|
|
127
|
+
profile.track_index,
|
|
128
|
+
profile.device_index,
|
|
129
|
+
exc_info=True,
|
|
130
|
+
)
|
|
119
131
|
continue
|
|
120
132
|
if maybe is not None:
|
|
121
133
|
results.append(maybe)
|
|
@@ -103,8 +103,11 @@ def _pick_target_modulator(
|
|
|
103
103
|
return None
|
|
104
104
|
candidates.sort(reverse=True) # highest level first
|
|
105
105
|
top_level, top_op = candidates[0]
|
|
106
|
-
# If every modulator is silent
|
|
107
|
-
#
|
|
106
|
+
# If every modulator is silent (Level <= 0), shifting its Coarse produces
|
|
107
|
+
# no audible change. Return None so the caller falls through to
|
|
108
|
+
# _fallback_carrier_target and targets an audible carrier instead.
|
|
109
|
+
if top_level <= 0.0:
|
|
110
|
+
return None
|
|
108
111
|
return top_op
|
|
109
112
|
|
|
110
113
|
|
|
@@ -48,8 +48,8 @@ from .base import register_adapter
|
|
|
48
48
|
# corpus (see skills/livepilot-core/references/device-knowledge/
|
|
49
49
|
# instruments-synths.md). PR9 uses a small subset; later PRs extend.
|
|
50
50
|
_KNOWN_PARAMS = {
|
|
51
|
-
"Osc 1
|
|
52
|
-
"Osc 2
|
|
51
|
+
"Osc 1 Pos",
|
|
52
|
+
"Osc 2 Pos",
|
|
53
53
|
"Osc 1 Transpose",
|
|
54
54
|
"Osc 2 Transpose",
|
|
55
55
|
"Voices",
|
|
@@ -220,7 +220,7 @@ class WavetableAdapter:
|
|
|
220
220
|
# shift to that region's center. The actual shift magnitude
|
|
221
221
|
# (how close to the center) scales with freshness — low
|
|
222
222
|
# freshness stops partway, high freshness commits fully.
|
|
223
|
-
current_pos = float(profile.parameter_state.get("Osc 1
|
|
223
|
+
current_pos = float(profile.parameter_state.get("Osc 1 Pos", 0.0) or 0.0)
|
|
224
224
|
current_region = _classify_position(current_pos)
|
|
225
225
|
target_region = _choose_target_region(current_region, target)
|
|
226
226
|
region_target_pos = _region_center(target_region)
|
|
@@ -281,7 +281,7 @@ class WavetableAdapter:
|
|
|
281
281
|
"params": {
|
|
282
282
|
"track_index": track,
|
|
283
283
|
"device_index": device,
|
|
284
|
-
"parameter_name": "Osc 1
|
|
284
|
+
"parameter_name": "Osc 1 Pos",
|
|
285
285
|
"value": new_pos,
|
|
286
286
|
},
|
|
287
287
|
},
|
|
@@ -62,6 +62,12 @@ class SectionNode:
|
|
|
62
62
|
density: float # 0.0-1.0 (how many tracks are active)
|
|
63
63
|
tracks_active: list[int] = field(default_factory=list)
|
|
64
64
|
name: str = ""
|
|
65
|
+
# Real session scene/row index this section maps to (the clip slot to
|
|
66
|
+
# read notes from). -1 means "not scene-backed" (e.g. built from the
|
|
67
|
+
# arrangement view), in which case callers should fall back to the
|
|
68
|
+
# section's position in the graph. Kept last so existing positional
|
|
69
|
+
# SectionNode(...) constructions stay valid.
|
|
70
|
+
scene_index: int = -1
|
|
65
71
|
|
|
66
72
|
def length_bars(self) -> int:
|
|
67
73
|
return self.end_bar - self.start_bar
|
|
@@ -112,6 +112,10 @@ def build_section_graph_from_scenes(
|
|
|
112
112
|
density=density,
|
|
113
113
|
tracks_active=active_tracks,
|
|
114
114
|
name=scene_name,
|
|
115
|
+
# Real session scene row — used as the get_notes clip_index.
|
|
116
|
+
# Differs from the section's position in this list whenever
|
|
117
|
+
# earlier unnamed/empty scenes were skipped above.
|
|
118
|
+
scene_index=i,
|
|
115
119
|
))
|
|
116
120
|
current_bar = end_bar
|
|
117
121
|
|
|
@@ -171,6 +171,18 @@ async def _try_native_replace_sample(
|
|
|
171
171
|
return resp
|
|
172
172
|
|
|
173
173
|
|
|
174
|
+
def _normalize_native_fallback_reason(skip_reason: Optional[str]) -> Optional[str]:
|
|
175
|
+
if not skip_reason:
|
|
176
|
+
return None
|
|
177
|
+
if skip_reason.startswith("gate_closed:"):
|
|
178
|
+
return "live_version_below_12_4"
|
|
179
|
+
return skip_reason
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _native_dispatch_was_attempted(skip_reason: Optional[str]) -> bool:
|
|
183
|
+
return bool(skip_reason) and not skip_reason.startswith("gate_closed:")
|
|
184
|
+
|
|
185
|
+
|
|
174
186
|
@mcp.tool()
|
|
175
187
|
async def reconnect_bridge(ctx: Context) -> dict:
|
|
176
188
|
"""Attempt to reconnect the M4L UDP bridge (port 9880).
|
|
@@ -627,6 +639,9 @@ async def replace_simpler_sample(
|
|
|
627
639
|
result = dict(native)
|
|
628
640
|
result.update(hygiene)
|
|
629
641
|
result["method"] = "native_12_4" # preserved in case hygiene ever adds its own key
|
|
642
|
+
result["native_attempted"] = True
|
|
643
|
+
result["bridge_attempted"] = False
|
|
644
|
+
result["fallback_reason"] = None
|
|
630
645
|
return result
|
|
631
646
|
|
|
632
647
|
# Pre-12.4 fallback: M4L bridge path (unchanged behavior).
|
|
@@ -636,11 +651,17 @@ async def replace_simpler_sample(
|
|
|
636
651
|
)
|
|
637
652
|
|
|
638
653
|
if "error" in result:
|
|
654
|
+
result["native_attempted"] = _native_dispatch_was_attempted(skip_reason)
|
|
655
|
+
result["bridge_attempted"] = True
|
|
656
|
+
result["fallback_reason"] = _normalize_native_fallback_reason(skip_reason)
|
|
639
657
|
return result
|
|
640
658
|
if not result.get("sample_loaded"):
|
|
641
659
|
return {
|
|
642
660
|
"error": "Sample may not have loaded. Ensure the Simpler already "
|
|
643
|
-
"has a sample loaded — replace_sample silently fails on empty Simplers."
|
|
661
|
+
"has a sample loaded — replace_sample silently fails on empty Simplers.",
|
|
662
|
+
"native_attempted": _native_dispatch_was_attempted(skip_reason),
|
|
663
|
+
"bridge_attempted": True,
|
|
664
|
+
"fallback_reason": _normalize_native_fallback_reason(skip_reason),
|
|
644
665
|
}
|
|
645
666
|
|
|
646
667
|
hygiene = await _simpler_post_load_hygiene(
|
|
@@ -652,6 +673,9 @@ async def replace_simpler_sample(
|
|
|
652
673
|
|
|
653
674
|
result.update(hygiene)
|
|
654
675
|
result["method"] = "bridge_m4l"
|
|
676
|
+
result["native_attempted"] = _native_dispatch_was_attempted(skip_reason)
|
|
677
|
+
result["bridge_attempted"] = True
|
|
678
|
+
result["fallback_reason"] = _normalize_native_fallback_reason(skip_reason)
|
|
655
679
|
if skip_reason:
|
|
656
680
|
result["native_skip_reason"] = skip_reason
|
|
657
681
|
return result
|
|
@@ -692,7 +716,10 @@ async def load_sample_to_simpler(
|
|
|
692
716
|
# Live 12.4+: create an empty Simpler via insert_device, then use the
|
|
693
717
|
# native replace_sample path. Skips the dummy-sample bootstrap entirely.
|
|
694
718
|
caps = _live_caps(ctx)
|
|
719
|
+
native_attempted = False
|
|
720
|
+
fallback_reason = "live_version_below_12_4"
|
|
695
721
|
if caps.has_replace_sample_native:
|
|
722
|
+
fallback_reason = "native_insert_device_unavailable"
|
|
696
723
|
try:
|
|
697
724
|
ins = ableton.send_command("insert_device", {
|
|
698
725
|
"track_index": track_index,
|
|
@@ -701,6 +728,7 @@ async def load_sample_to_simpler(
|
|
|
701
728
|
except Exception:
|
|
702
729
|
ins = None
|
|
703
730
|
if isinstance(ins, dict) and "error" not in ins:
|
|
731
|
+
native_attempted = True
|
|
704
732
|
actual_device_index = ins.get("device_index", device_index)
|
|
705
733
|
native = await _try_native_replace_sample(
|
|
706
734
|
ctx, track_index, actual_device_index, file_path
|
|
@@ -717,7 +745,13 @@ async def load_sample_to_simpler(
|
|
|
717
745
|
result["method"] = "native_12_4"
|
|
718
746
|
result["device_index"] = actual_device_index
|
|
719
747
|
result["track_index"] = track_index
|
|
748
|
+
result["native_attempted"] = True
|
|
749
|
+
result["bridge_attempted"] = False
|
|
750
|
+
result["fallback_reason"] = None
|
|
720
751
|
return result
|
|
752
|
+
fallback_reason = _normalize_native_fallback_reason(
|
|
753
|
+
ctx.lifespan_context.get("_native_replace_skip_reason")
|
|
754
|
+
) or "native_replace_failed"
|
|
721
755
|
# Fall through to the legacy bootstrap path below on any failure.
|
|
722
756
|
|
|
723
757
|
# Step 1: Load a sample from the browser to create Simpler with content
|
|
@@ -774,6 +808,9 @@ async def load_sample_to_simpler(
|
|
|
774
808
|
result["method"] = "bootstrap_and_replace"
|
|
775
809
|
result["device_index"] = actual_device_index # additive — for step-result binding
|
|
776
810
|
result["track_index"] = track_index
|
|
811
|
+
result["native_attempted"] = native_attempted
|
|
812
|
+
result["bridge_attempted"] = True
|
|
813
|
+
result["fallback_reason"] = fallback_reason
|
|
777
814
|
return result
|
|
778
815
|
|
|
779
816
|
|
|
@@ -380,9 +380,10 @@ async def check_clip_key_consistency(
|
|
|
380
380
|
# 1) Resolve the clip's file path. Relies on the M4L bridge.
|
|
381
381
|
try:
|
|
382
382
|
from .analyzer import get_clip_file_path as _get_path
|
|
383
|
-
#
|
|
384
|
-
#
|
|
385
|
-
|
|
383
|
+
# Under FastMCP 3.3.1 @mcp.tool() returns the plain async function
|
|
384
|
+
# (no .fn accessor), so we call it directly for composition — the
|
|
385
|
+
# same pattern analyzer.verify_all_devices_health uses.
|
|
386
|
+
path_resp = await _get_path(ctx, track_index, clip_index)
|
|
386
387
|
except Exception as exc:
|
|
387
388
|
return {
|
|
388
389
|
"track_index": track_index,
|
|
@@ -414,7 +415,7 @@ async def check_clip_key_consistency(
|
|
|
414
415
|
# 3) Query the session-detected key (needs the analyzer).
|
|
415
416
|
try:
|
|
416
417
|
from .analyzer import get_detected_key as _get_key
|
|
417
|
-
key_resp = await _get_key
|
|
418
|
+
key_resp = await _get_key(ctx)
|
|
418
419
|
except Exception as exc:
|
|
419
420
|
return {
|
|
420
421
|
"track_index": track_index,
|
|
@@ -408,12 +408,16 @@ def get_harmony_field(
|
|
|
408
408
|
for i, t in enumerate(tracks)}
|
|
409
409
|
|
|
410
410
|
# Per-track scan: fetch notes + score, then sort by score desc.
|
|
411
|
+
# Use the section's real scene row (scene_index) for the clip slot,
|
|
412
|
+
# not section_index (its position in the section graph) — these
|
|
413
|
+
# diverge whenever earlier unnamed/empty scenes were skipped.
|
|
414
|
+
scene_idx = section.scene_index if getattr(section, "scene_index", -1) >= 0 else section_index
|
|
411
415
|
HARMONIC_THRESHOLD = 0.3
|
|
412
416
|
candidates: list[tuple[float, int, list[dict]]] = []
|
|
413
417
|
for t_idx in section.tracks_active:
|
|
414
418
|
try:
|
|
415
419
|
result = ableton.send_command("get_notes", {
|
|
416
|
-
"track_index": t_idx, "clip_index":
|
|
420
|
+
"track_index": t_idx, "clip_index": scene_idx,
|
|
417
421
|
})
|
|
418
422
|
except Exception as exc:
|
|
419
423
|
logger.debug("harmony scan track %d: %s", t_idx, exc)
|
|
@@ -34,6 +34,12 @@ def _require_midiutil():
|
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
# Hard cap on extract_piano_roll's emitted matrix (pitch_range * time_steps).
|
|
38
|
+
# ~16k cells keeps the JSON response well inside a single context window even
|
|
39
|
+
# for a full 88-key range; coarsen 'resolution' to fit larger material.
|
|
40
|
+
_PIANO_ROLL_CELL_BUDGET = 16000
|
|
41
|
+
|
|
42
|
+
|
|
37
43
|
def _require_pretty_midi():
|
|
38
44
|
try:
|
|
39
45
|
import pretty_midi
|
|
@@ -348,7 +354,20 @@ def extract_piano_roll(
|
|
|
348
354
|
|
|
349
355
|
Returns a velocity matrix [pitch_index][time_step] trimmed to
|
|
350
356
|
the actual pitch range. Resolution is in beats (0.125 = 32nd note).
|
|
357
|
+
|
|
358
|
+
To keep the response bounded, the emitted matrix is capped at
|
|
359
|
+
``_PIANO_ROLL_CELL_BUDGET`` cells (pitch_range * time_steps). When the
|
|
360
|
+
full roll exceeds the budget the tool returns a structured error with the
|
|
361
|
+
offending dimensions instead of a multi-MB matrix; coarsen ``resolution``
|
|
362
|
+
(larger value = fewer time steps) to fit.
|
|
351
363
|
"""
|
|
364
|
+
if not resolution or resolution <= 0:
|
|
365
|
+
return {
|
|
366
|
+
"error": "resolution must be a positive number of beats per step "
|
|
367
|
+
f"(got {resolution!r}); e.g. 0.125 for 32nd notes.",
|
|
368
|
+
"code": "INVALID_PARAM",
|
|
369
|
+
}
|
|
370
|
+
|
|
352
371
|
pretty_midi = _require_pretty_midi()
|
|
353
372
|
path = _validate_midi_path(file_path)
|
|
354
373
|
pm = pretty_midi.PrettyMIDI(str(path))
|
|
@@ -373,10 +392,30 @@ def extract_piano_roll(
|
|
|
373
392
|
pitch_max = int(active_pitches[-1])
|
|
374
393
|
trimmed = roll[pitch_min:pitch_max + 1, :]
|
|
375
394
|
|
|
395
|
+
pitch_range = int(trimmed.shape[0])
|
|
396
|
+
time_steps = int(trimmed.shape[1])
|
|
397
|
+
cell_count = pitch_range * time_steps
|
|
398
|
+
if cell_count > _PIANO_ROLL_CELL_BUDGET:
|
|
399
|
+
return {
|
|
400
|
+
"error": (
|
|
401
|
+
f"piano roll too large: {pitch_range} pitches x {time_steps} "
|
|
402
|
+
f"steps = {cell_count} cells exceeds the {_PIANO_ROLL_CELL_BUDGET}"
|
|
403
|
+
"-cell budget. Increase 'resolution' (e.g. 0.25 or 0.5 beats) "
|
|
404
|
+
"to coarsen the time axis."
|
|
405
|
+
),
|
|
406
|
+
"code": "INVALID_PARAM",
|
|
407
|
+
"pitch_min": pitch_min,
|
|
408
|
+
"pitch_max": pitch_max,
|
|
409
|
+
"pitch_range": pitch_range,
|
|
410
|
+
"time_steps": time_steps,
|
|
411
|
+
"cell_budget": _PIANO_ROLL_CELL_BUDGET,
|
|
412
|
+
"resolution": resolution,
|
|
413
|
+
}
|
|
414
|
+
|
|
376
415
|
return {
|
|
377
416
|
"piano_roll": trimmed.astype(int).tolist(),
|
|
378
417
|
"pitch_min": pitch_min,
|
|
379
418
|
"pitch_max": pitch_max,
|
|
380
|
-
"time_steps":
|
|
419
|
+
"time_steps": time_steps,
|
|
381
420
|
"resolution": resolution,
|
|
382
421
|
}
|
|
@@ -167,7 +167,7 @@ async def get_session_diagnostics(ctx: Context, check_clip_keys: bool = False) -
|
|
|
167
167
|
# reasonable upper bound for typical production sessions.
|
|
168
168
|
for clip_idx in range(min(32, len(session_info.get("scenes", []) or []) or 8)):
|
|
169
169
|
try:
|
|
170
|
-
check = await check_clip_key_consistency
|
|
170
|
+
check = await check_clip_key_consistency(ctx, t_idx, clip_idx)
|
|
171
171
|
except Exception: # noqa: BLE001 — any failure means "skip this clip"
|
|
172
172
|
continue
|
|
173
173
|
if not isinstance(check, dict):
|
|
@@ -105,6 +105,62 @@ class DetectedPlugin:
|
|
|
105
105
|
# ─── Top-level entry ────────────────────────────────────────────────────────
|
|
106
106
|
|
|
107
107
|
|
|
108
|
+
# Bundle file/dir extensions per plugin format. VST3/AU/AAX/LV2 bundles are
|
|
109
|
+
# themselves directories (Foo.vst3/Contents/...), so the recursive scan treats
|
|
110
|
+
# a matching entry as a leaf — it records it but never descends inside.
|
|
111
|
+
_BUNDLE_EXTS: dict[str, tuple[str, ...]] = {
|
|
112
|
+
"VST3": (".vst3",),
|
|
113
|
+
"AU": (".component",),
|
|
114
|
+
"VST2": (".vst", ".dylib"),
|
|
115
|
+
"AAX": (".aaxplugin",),
|
|
116
|
+
"LV2": (".lv2",),
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _is_plugin_bundle(path: Path, fmt: str) -> bool:
|
|
121
|
+
"""True when *path* is itself a plugin bundle/file for *fmt* (a leaf to
|
|
122
|
+
record) rather than a vendor/organisational subfolder to recurse into."""
|
|
123
|
+
return path.suffix in _BUNDLE_EXTS.get(fmt, ())
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _walk_plugin_bundles(root: Path, fmt: str, max_depth: int = 8):
|
|
127
|
+
"""Yield every *fmt* plugin bundle/file under *root*, recursing into plain
|
|
128
|
+
(vendor) subdirectories but NOT descending into bundle directories.
|
|
129
|
+
|
|
130
|
+
Fixes the flat scan that only saw top-level bundles: plugins nested in
|
|
131
|
+
vendor subfolders (e.g. VST3/Arturia/Analog Lab.vst3) were invisible, and
|
|
132
|
+
the vendor folders themselves were mis-emitted as junk 'unknown-*' records.
|
|
133
|
+
Symlink cycles are guarded via resolved-path dedup; recursion depth is
|
|
134
|
+
capped; unreadable directories are skipped with a warning.
|
|
135
|
+
"""
|
|
136
|
+
seen_dirs: set[Path] = set()
|
|
137
|
+
stack: list[tuple[Path, int]] = [(root, 0)]
|
|
138
|
+
while stack:
|
|
139
|
+
current, depth = stack.pop()
|
|
140
|
+
try:
|
|
141
|
+
real = current.resolve()
|
|
142
|
+
except OSError:
|
|
143
|
+
continue
|
|
144
|
+
if real in seen_dirs:
|
|
145
|
+
continue
|
|
146
|
+
seen_dirs.add(real)
|
|
147
|
+
try:
|
|
148
|
+
entries = sorted(current.iterdir())
|
|
149
|
+
except (PermissionError, OSError) as e:
|
|
150
|
+
logger.warning("Cannot read %s: %s", current, e)
|
|
151
|
+
continue
|
|
152
|
+
for entry in entries:
|
|
153
|
+
if _is_plugin_bundle(entry, fmt):
|
|
154
|
+
yield entry # leaf — never descend into a bundle
|
|
155
|
+
elif depth < max_depth:
|
|
156
|
+
try:
|
|
157
|
+
descend = entry.is_dir()
|
|
158
|
+
except OSError:
|
|
159
|
+
descend = False
|
|
160
|
+
if descend:
|
|
161
|
+
stack.append((entry, depth + 1))
|
|
162
|
+
|
|
163
|
+
|
|
108
164
|
def detect_installed_plugins(
|
|
109
165
|
paths: list[tuple[Path, str]] | None = None,
|
|
110
166
|
formats: list[str] | None = None,
|
|
@@ -138,20 +194,19 @@ def detect_installed_plugins(
|
|
|
138
194
|
results: list[DetectedPlugin] = []
|
|
139
195
|
seen_keys: set[tuple[str, str, str]] = set() # (vendor_lc, name_lc, format)
|
|
140
196
|
|
|
141
|
-
# 1. Path-based scan — covers VST3 / VST2 / AAX / LV2 + co-located AU v2
|
|
197
|
+
# 1. Path-based scan — covers VST3 / VST2 / AAX / LV2 + co-located AU v2.
|
|
198
|
+
# Recurses into vendor subfolders (e.g. VST3/Arturia/Foo.vst3) but never
|
|
199
|
+
# descends into bundle directories themselves. See _walk_plugin_bundles.
|
|
142
200
|
for root, fmt in paths:
|
|
143
201
|
if not root.exists():
|
|
144
202
|
continue
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
results.append(plugin)
|
|
153
|
-
except (PermissionError, OSError) as e:
|
|
154
|
-
logger.warning("Cannot read %s: %s", root, e)
|
|
203
|
+
for entry in _walk_plugin_bundles(root, fmt):
|
|
204
|
+
plugin = _identify_plugin(entry, fmt)
|
|
205
|
+
if plugin:
|
|
206
|
+
key = ((plugin.vendor or "").lower(), plugin.name.lower(), plugin.format)
|
|
207
|
+
if key not in seen_keys:
|
|
208
|
+
seen_keys.add(key)
|
|
209
|
+
results.append(plugin)
|
|
155
210
|
|
|
156
211
|
# 2. auval-based AU enumeration — captures AUv3 + arbitrary-location AUs
|
|
157
212
|
want_au = formats is None or "AU" in (formats or [])
|
|
@@ -11,6 +11,7 @@ mtime-based incremental skipping is on by default.
|
|
|
11
11
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
|
+
import fnmatch
|
|
14
15
|
import hashlib
|
|
15
16
|
import json
|
|
16
17
|
import logging
|
|
@@ -181,7 +182,12 @@ def _iter_files(
|
|
|
181
182
|
continue
|
|
182
183
|
if not scanner.is_applicable(p):
|
|
183
184
|
continue
|
|
184
|
-
|
|
185
|
+
# Honor excludes against BOTH the filename (Path.match, right-anchored —
|
|
186
|
+
# keeps filename-glob patterns like "*.tmp" working) and the full path
|
|
187
|
+
# string (fnmatch — lets directory patterns like "*Backup*" exclude
|
|
188
|
+
# files *inside* a Backup/ folder, which Path.match alone cannot do).
|
|
189
|
+
path_str = p.as_posix()
|
|
190
|
+
if any(p.match(g) or fnmatch.fnmatch(path_str, g) for g in excludes):
|
|
185
191
|
continue
|
|
186
192
|
yield p
|
|
187
193
|
|
|
@@ -143,17 +143,26 @@ class AmxdScanner(Scanner):
|
|
|
143
143
|
# ─── Parsing ─────────────────────────────────────────────────────────────────
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
# The ampf header carries device type as
|
|
147
|
-
# '
|
|
148
|
-
# '
|
|
149
|
-
# '
|
|
146
|
+
# The ampf header carries device type as a 4-byte ASCII tag at offset 8:
|
|
147
|
+
# 'aaaa' = audio effect
|
|
148
|
+
# 'iiii' = instrument
|
|
149
|
+
# 'mmmm' = MIDI effect
|
|
150
|
+
# 'nagg' = MIDI Tool generator (Live 12.1+)
|
|
151
|
+
# 'natt' = MIDI Tool transformation (Live 12.1+)
|
|
150
152
|
# Earlier guess of 0/1/2 was wrong — verified against the user's 393-file
|
|
151
153
|
# real-world .amxd corpus where 388/393 devices reported as unknown-{97,109,105}.
|
|
154
|
+
# The single-letter map predates the MIDI Tool surface: both MIDI Tool kinds
|
|
155
|
+
# share first byte 'n' (110), so a single-byte read mis-tagged them as
|
|
156
|
+
# unknown-110 and could not tell generator from transformation. Keying off the
|
|
157
|
+
# full 4-byte tag (raw[8:12]) fixes both. The first-byte fallback preserves the
|
|
158
|
+
# legacy unknown-{byte} shape for any tag we don't recognise.
|
|
152
159
|
_AMPF_DEVICE_TYPE_BYTE = 8
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
_DEVICE_TYPE_TAG_MAP = {
|
|
161
|
+
b"aaaa": "audio",
|
|
162
|
+
b"iiii": "instrument",
|
|
163
|
+
b"mmmm": "midi",
|
|
164
|
+
b"nagg": "midi_tool_generator",
|
|
165
|
+
b"natt": "midi_tool_transformation",
|
|
157
166
|
}
|
|
158
167
|
|
|
159
168
|
|
|
@@ -174,11 +183,13 @@ def _parse_amxd(raw: bytes, filename: str) -> dict:
|
|
|
174
183
|
|
|
175
184
|
# 1. Device type from the ampf header
|
|
176
185
|
if len(raw) > 24 and raw[:4] == b"ampf":
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
186
|
+
tag = raw[_AMPF_DEVICE_TYPE_BYTE:_AMPF_DEVICE_TYPE_BYTE + 4]
|
|
187
|
+
known = _DEVICE_TYPE_TAG_MAP.get(tag)
|
|
188
|
+
if known is not None:
|
|
189
|
+
out["device_type"] = known
|
|
190
|
+
else:
|
|
191
|
+
# Fall back to the legacy single-byte unknown-{byte} shape.
|
|
192
|
+
out["device_type"] = f"unknown-{tag[0]}" if tag else None
|
|
182
193
|
|
|
183
194
|
# 2. Locate + parse the JSON patcher block
|
|
184
195
|
json_blob = _extract_patcher_json(raw)
|