@mthines/reaper-mcp 0.75.0-beta.89.1 → 0.75.0
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/README.md +37 -37
- package/bridge-ui/mcp_bridge.html +4 -4
- package/main.js +12 -2
- package/package.json +1 -1
- package/sidecar/tests/test_verify.py +3 -28
- package/sidecar/verify.py +6 -19
package/main.js
CHANGED
|
@@ -390,6 +390,13 @@ async function shutdownTelemetry() {
|
|
|
390
390
|
function getTracer() {
|
|
391
391
|
return trace.getTracer(SCOPE_NAME);
|
|
392
392
|
}
|
|
393
|
+
var CLIENT_CONNECTED_SPAN = "mcp client connected";
|
|
394
|
+
function recordClientConnected(tracer = getTracer()) {
|
|
395
|
+
tracer.startSpan(CLIENT_CONNECTED_SPAN, {
|
|
396
|
+
kind: SpanKind.INTERNAL,
|
|
397
|
+
attributes: { "mcp.method.name": "notifications/initialized" }
|
|
398
|
+
}).end();
|
|
399
|
+
}
|
|
393
400
|
function getMeter() {
|
|
394
401
|
return metrics.getMeter(SCOPE_NAME);
|
|
395
402
|
}
|
|
@@ -5928,7 +5935,7 @@ function registerOfflineTools(server) {
|
|
|
5928
5935
|
);
|
|
5929
5936
|
server.tool(
|
|
5930
5937
|
"verify_edit",
|
|
5931
|
-
`Check the result of an edit you just made, since you cannot hear it: compare the edited track with the audio from before the edit and get a verdict per check. Compensated null: the delay (ms, + = later), gain (dB) and polarity between the two are estimated and removed, and the residual left (dB below the reference) says whether anything else changed (noise, a splice, a different waveform, a swapped stereo channel; it is relative to referenceRmsDb, so with a quiet reference the rounding noise of a 16-bit bounce can set it). Discontinuity: the largest sample-to-sample jump on any channel against the reference's own, with where it happens and which channel (a click or hard splice). Use expect 'identical' (default) for edits that should leave the sound alone apart from level, delay and polarity (alignment, gain, split, crossfade): the residual is judged ok/warn/fail. Use "changed" for EQ, compression and the like: the residual is reported without a verdict. Set timeScale to the playback rate when the edit changed the timing (1.1 = the edit is 10% shorter): the waveform null is then skipped and the click check runs with three warn-only character checks against the reference warped through that rate: pitch drift in cents (skipped for unpitched material), tone (long-term spectrum distance in dB
|
|
5938
|
+
`Check the result of an edit you just made, since you cannot hear it: compare the edited track with the audio from before the edit and get a verdict per check. Compensated null: the delay (ms, + = later), gain (dB) and polarity between the two are estimated and removed, and the residual left (dB below the reference) says whether anything else changed (noise, a splice, a different waveform, a swapped stereo channel; it is relative to referenceRmsDb, so with a quiet reference the rounding noise of a 16-bit bounce can set it). Discontinuity: the largest sample-to-sample jump on any channel against the reference's own, with where it happens and which channel (a click or hard splice). Use expect 'identical' (default) for edits that should leave the sound alone apart from level, delay and polarity (alignment, gain, split, crossfade): the residual is judged ok/warn/fail. Use "changed" for EQ, compression and the like: the residual is reported without a verdict. Set timeScale to the playback rate when the edit changed the timing (1.1 = the edit is 10% shorter): the waveform null is then skipped and the click check runs with three warn-only character checks against the reference warped through that rate: pitch drift in cents (skipped for unpitched material), tone (long-term spectrum distance in dB) and transients (smeared attacks). The reference is another track (e.g. a copy you kept) or an audio file of the same range from before the edit (a bounce), not an undo. Keep a reference track unmuted so it renders. The tone check misses a phase vocoder's smearing and the transient check is blind on drums. A passing result is evidence, not a replacement for listening. Requires the Python sidecar.`,
|
|
5932
5939
|
{
|
|
5933
5940
|
trackIndex: z28.coerce.number().int().min(0).describe("Zero-based index of the edited track"),
|
|
5934
5941
|
referenceTrack: z28.coerce.number().int().min(0).optional().describe("Zero-based index of a track holding the audio from before the edit (give this or referencePath)"),
|
|
@@ -9630,7 +9637,10 @@ async function serve() {
|
|
|
9630
9637
|
}
|
|
9631
9638
|
const transport = new StdioServerTransport();
|
|
9632
9639
|
await server.connect(transport);
|
|
9633
|
-
server.server.oninitialized = () =>
|
|
9640
|
+
server.server.oninitialized = () => {
|
|
9641
|
+
setSessionClient(server.server.getClientVersion()?.name);
|
|
9642
|
+
recordClientConnected();
|
|
9643
|
+
};
|
|
9634
9644
|
startSessionPing();
|
|
9635
9645
|
startupSpan.setStatus({ code: SpanStatusCode4.OK });
|
|
9636
9646
|
log("MCP server connected via stdio");
|
package/package.json
CHANGED
|
@@ -270,35 +270,11 @@ def test_a_stretch_that_keeps_the_pitch_passes_every_character_check():
|
|
|
270
270
|
assert checks["transients"]["verdict"] == "ok"
|
|
271
271
|
|
|
272
272
|
|
|
273
|
-
def
|
|
273
|
+
def test_varispeed_is_reported_as_pitch_drift_in_cents():
|
|
274
274
|
reference = _voice(4)
|
|
275
275
|
checks = _character(reference, _resampled(reference, 1.1), 1.1)
|
|
276
|
-
assert checks["pitch"]["verdict"] == "info"
|
|
277
|
-
assert checks["pitch"]["varispeed"] is True
|
|
278
|
-
assert checks["pitch"]["driftCents"] == pytest.approx(1200 * np.log2(1.1), abs=15)
|
|
279
|
-
assert checks["pitch"]["expectedCents"] == pytest.approx(1200 * np.log2(1.1), abs=0.2)
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
def test_a_slow_down_that_moves_the_pitch_is_also_a_plain_speed_change():
|
|
283
|
-
reference = _voice(4)
|
|
284
|
-
checks = _character(reference, _resampled(reference, 0.92), 0.92)
|
|
285
|
-
assert checks["pitch"]["verdict"] == "info"
|
|
286
|
-
assert checks["pitch"]["driftCents"] < -100
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
def test_a_pitch_error_the_speed_change_does_not_explain_still_warns_after_a_speed_change():
|
|
290
|
-
reference = _voice(4)
|
|
291
|
-
off = _resampled(_voice(4, pitch_scale=2 ** (1.0 / 12)), 1.1) # a semitone further up than the speed alone
|
|
292
|
-
checks = _character(reference, off, 1.1)
|
|
293
276
|
assert checks["pitch"]["verdict"] == "warn"
|
|
294
|
-
assert
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
def test_the_tone_shift_of_a_speed_change_is_reported_not_warned():
|
|
298
|
-
reference = _voice(4)
|
|
299
|
-
checks = _character(reference, _resampled(reference, 1.25), 1.25)
|
|
300
|
-
assert checks["tone"]["distanceDb"] >= verify.TONE_WARN_DB
|
|
301
|
-
assert checks["tone"]["verdict"] == "info"
|
|
277
|
+
assert checks["pitch"]["driftCents"] == pytest.approx(1200 * np.log2(1.1), abs=15)
|
|
302
278
|
|
|
303
279
|
|
|
304
280
|
def test_a_half_semitone_error_is_found():
|
|
@@ -337,6 +313,5 @@ def test_character_checks_only_run_when_the_timing_changed(source):
|
|
|
337
313
|
|
|
338
314
|
def test_a_character_warning_makes_the_verdict_a_warning_never_a_fail():
|
|
339
315
|
reference = _voice(4)
|
|
340
|
-
|
|
341
|
-
result = verify.verify_edit(reference, off, SR, time_scale=1.1)
|
|
316
|
+
result = verify.verify_edit(reference, _resampled(reference, 1.1), SR, time_scale=1.1)
|
|
342
317
|
assert result["verdict"] == "warn"
|
package/sidecar/verify.py
CHANGED
|
@@ -44,9 +44,7 @@ SILENCE = 1e-6
|
|
|
44
44
|
|
|
45
45
|
# Character checks (only when the timing changed): warn lines from the issue 81 experiment
|
|
46
46
|
PITCH_WARN_CENTS = 20.0
|
|
47
|
-
TONE_WARN_DB =
|
|
48
|
-
# A drift this close to what the speed change alone predicts is a plain speed change (varispeed), reported, not warned
|
|
49
|
-
VARISPEED_TOLERANCE_CENTS = 35.0
|
|
47
|
+
TONE_WARN_DB = 0.7
|
|
50
48
|
TRANSIENT_WARN_LOG = -0.25
|
|
51
49
|
MIN_VOICED_FRAMES = 12
|
|
52
50
|
MIN_VOICED_SHARE = 0.25
|
|
@@ -253,14 +251,11 @@ def pitch_drift(reference: np.ndarray, edited: np.ndarray, sample_rate: int, rat
|
|
|
253
251
|
return {"verdict": "skipped", "reason": "too few voiced frames in both to compare"}
|
|
254
252
|
cents = 1200.0 * np.log2(edit_f0[both] / ref_f0[index][both])
|
|
255
253
|
drift = float(np.median(cents))
|
|
256
|
-
expected = 1200.0 * np.log2(rate) # what a plain speed change (pitch follows the speed) would do
|
|
257
|
-
varispeed = abs(expected) >= PITCH_WARN_CENTS and abs(drift - expected) <= VARISPEED_TOLERANCE_CENTS
|
|
258
254
|
return {
|
|
259
|
-
"verdict": "
|
|
255
|
+
"verdict": "warn" if abs(drift) >= PITCH_WARN_CENTS else "ok",
|
|
260
256
|
"driftCents": round(drift, 1),
|
|
261
257
|
"referenceHz": round(centre, 1),
|
|
262
258
|
"framesCompared": int(both.sum()),
|
|
263
|
-
**({"varispeed": True, "expectedCents": round(expected, 1)} if varispeed else {}),
|
|
264
259
|
}
|
|
265
260
|
|
|
266
261
|
|
|
@@ -284,19 +279,11 @@ def _long_term_bands(x: np.ndarray, sample_rate: int) -> np.ndarray:
|
|
|
284
279
|
return levels[frame_level > frame_level.max() - 40.0].mean(axis=0)
|
|
285
280
|
|
|
286
281
|
|
|
287
|
-
def tone_difference(reference: np.ndarray, edited: np.ndarray, sample_rate: int
|
|
288
|
-
"""
|
|
289
|
-
Rms dB difference of the long-term spectrum, overall gain removed. After a plain speed change the whole
|
|
290
|
-
spectrum moves with the pitch by design, so a distance over the line is reported, not warned.
|
|
291
|
-
"""
|
|
282
|
+
def tone_difference(reference: np.ndarray, edited: np.ndarray, sample_rate: int) -> dict[str, Any]:
|
|
283
|
+
"""Rms dB difference of the long-term spectrum, overall gain removed."""
|
|
292
284
|
delta = _long_term_bands(reference, sample_rate) - _long_term_bands(edited, sample_rate)
|
|
293
285
|
distance = float(np.sqrt(np.mean((delta - delta.mean()) ** 2)))
|
|
294
|
-
|
|
295
|
-
return {
|
|
296
|
-
"verdict": ("info" if varispeed else "warn") if over else "ok",
|
|
297
|
-
"distanceDb": round(distance, 2),
|
|
298
|
-
**({"reason": "the spectrum moves with the pitch after a plain speed change"} if over and varispeed else {}),
|
|
299
|
-
}
|
|
286
|
+
return {"verdict": "warn" if distance >= TONE_WARN_DB else "ok", "distanceDb": round(distance, 2)}
|
|
300
287
|
|
|
301
288
|
|
|
302
289
|
def _flux_peakiness(x: np.ndarray) -> float:
|
|
@@ -368,7 +355,7 @@ def verify_edit(reference: np.ndarray, edited: np.ndarray, sample_rate: int, *,
|
|
|
368
355
|
checks["null"] = {"verdict": "skipped", "reason": "timing changed (timeScale != 1): a waveform null needs the same timing"}
|
|
369
356
|
ref_mono, edit_mono = _mono(reference), _mono(edited)
|
|
370
357
|
checks["pitch"] = pitch_drift(ref_mono, edit_mono, sample_rate, time_scale)
|
|
371
|
-
checks["tone"] = tone_difference(ref_mono, edit_mono, sample_rate
|
|
358
|
+
checks["tone"] = tone_difference(ref_mono, edit_mono, sample_rate)
|
|
372
359
|
checks["transients"] = transient_change(ref_mono, edit_mono)
|
|
373
360
|
else:
|
|
374
361
|
null = compensated_null(reference, edited, sample_rate, max_lag_ms)
|