@mthines/reaper-mcp 0.75.0-beta.89.1 → 0.75.0-beta.89.2
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 +1 -1
- package/main.js +4 -2
- package/package.json +1 -1
- package/sidecar/tests/test_verify.py +24 -0
- package/sidecar/verify.py +39 -0
package/main.js
CHANGED
|
@@ -5544,7 +5544,7 @@ function alignmentSummary(data) {
|
|
|
5544
5544
|
...data["warning"] ? { warn: 1 } : {}
|
|
5545
5545
|
};
|
|
5546
5546
|
}
|
|
5547
|
-
var VERIFY_CHECKS = ["null", "discontinuity", "pitch", "tone", "transients"];
|
|
5547
|
+
var VERIFY_CHECKS = ["null", "discontinuity", "pitch", "tone", "transients", "dropout"];
|
|
5548
5548
|
function verifyRow(key, c) {
|
|
5549
5549
|
const verdict = typeof c["verdict"] === "string" ? c["verdict"] : "unknown";
|
|
5550
5550
|
const f = (v, digits, unit) => num(v) === void 0 ? "" : `${num(v).toFixed(digits)}${unit}`;
|
|
@@ -5566,6 +5566,8 @@ function verifyRow(key, c) {
|
|
|
5566
5566
|
return [key, verdict, f(c["driftCents"], 0, " cents"), typeof c["reason"] === "string" ? c["reason"] : f(c["referenceHz"], 0, " Hz reference")];
|
|
5567
5567
|
case "tone":
|
|
5568
5568
|
return [key, verdict, f(c["distanceDb"], 2, " dB"), ""];
|
|
5569
|
+
case "dropout":
|
|
5570
|
+
return [key, verdict, f(c["deepestDipDb"], 1, " dB"), typeof c["reason"] === "string" ? c["reason"] : "deepest dip under the original"];
|
|
5569
5571
|
default:
|
|
5570
5572
|
return [key, verdict, f(c["fluxLogRatio"], 2, ""), typeof c["reason"] === "string" ? c["reason"] : ""];
|
|
5571
5573
|
}
|
|
@@ -5928,7 +5930,7 @@ function registerOfflineTools(server) {
|
|
|
5928
5930
|
);
|
|
5929
5931
|
server.tool(
|
|
5930
5932
|
"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, line 1.5 dB, provisional) and transients (smeared attacks). When the pitch moved by what the speed change alone causes (a plain speed change, pitch follows speed), pitch and tone are reported as info, not warned; a pitch move the speed does not explain still warns.
|
|
5933
|
+
`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, line 1.5 dB, provisional) and transients (smeared attacks). When the pitch moved by what the speed change alone causes (a plain speed change, pitch follows speed), pitch and tone are reported as info, not warned; a pitch move the speed does not explain still warns. Slow-downs below 0.9 also get a dropout check (the deepest dip of the edited loudness under the original, warn from 12 dB, provisional): bigger slow-downs stretch audible artifacts into a vocal that the other checks do not hear, so listen to those either way. 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
5934
|
{
|
|
5933
5935
|
trackIndex: z28.coerce.number().int().min(0).describe("Zero-based index of the edited track"),
|
|
5934
5936
|
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)"),
|
package/package.json
CHANGED
|
@@ -340,3 +340,27 @@ def test_a_character_warning_makes_the_verdict_a_warning_never_a_fail():
|
|
|
340
340
|
off = _resampled(_voice(4, pitch_scale=2 ** (1.0 / 12)), 1.1)
|
|
341
341
|
result = verify.verify_edit(reference, off, SR, time_scale=1.1)
|
|
342
342
|
assert result["verdict"] == "warn"
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def _slowed(rate):
|
|
346
|
+
return _voice(4, rate=rate)
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def test_a_clean_big_slow_down_reports_a_shallow_dip_and_passes():
|
|
350
|
+
checks = _character(_voice(4), _slowed(0.8), 0.8)
|
|
351
|
+
assert checks["dropout"]["verdict"] == "ok"
|
|
352
|
+
assert checks["dropout"]["deepestDipDb"] < verify.DROPOUT_WARN_DB
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def test_a_piece_of_a_slow_down_that_went_missing_is_found():
|
|
356
|
+
edited = _slowed(0.8).copy()
|
|
357
|
+
mid = len(edited) // 2
|
|
358
|
+
edited[mid:mid + int(0.08 * SR)] *= 0.02 # 80 ms gone while the original keeps sounding there
|
|
359
|
+
checks = _character(_voice(4), edited, 0.8)
|
|
360
|
+
assert checks["dropout"]["verdict"] == "warn"
|
|
361
|
+
assert checks["dropout"]["deepestDipDb"] >= verify.DROPOUT_WARN_DB
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def test_mild_slow_downs_and_speed_ups_are_not_checked_for_dropouts():
|
|
365
|
+
assert "dropout" not in _character(_voice(4), _slowed(0.92), 0.92)
|
|
366
|
+
assert "dropout" not in _character(_voice(4), _voice(4, rate=1.1), 1.1)
|
package/sidecar/verify.py
CHANGED
|
@@ -47,6 +47,10 @@ PITCH_WARN_CENTS = 20.0
|
|
|
47
47
|
TONE_WARN_DB = 1.5
|
|
48
48
|
# A drift this close to what the speed change alone predicts is a plain speed change (varispeed), reported, not warned
|
|
49
49
|
VARISPEED_TOLERANCE_CENTS = 35.0
|
|
50
|
+
# Slow-downs below this rate stretch audible artifacts into a vocal (listening test, issue 81 follow-up: 0.80, 0.85
|
|
51
|
+
# and 0.88 had them, 0.90 and up did not). The dropout check runs only there; the line is provisional (one phrase).
|
|
52
|
+
DROPOUT_MAX_RATE = 0.9
|
|
53
|
+
DROPOUT_WARN_DB = 12.0
|
|
50
54
|
TRANSIENT_WARN_LOG = -0.25
|
|
51
55
|
MIN_VOICED_FRAMES = 12
|
|
52
56
|
MIN_VOICED_SHARE = 0.25
|
|
@@ -312,6 +316,39 @@ def transient_change(reference: np.ndarray, edited: np.ndarray) -> dict[str, Any
|
|
|
312
316
|
return {"verdict": "warn" if ratio <= TRANSIENT_WARN_LOG else "ok", "fluxLogRatio": round(ratio, 3)}
|
|
313
317
|
|
|
314
318
|
|
|
319
|
+
def _envelope_db(x: np.ndarray, sample_rate: int, window: float = 0.03, hop: float = 0.01) -> np.ndarray:
|
|
320
|
+
w, h = int(window * sample_rate), int(hop * sample_rate)
|
|
321
|
+
frames = (len(x) - w) // h
|
|
322
|
+
return 10.0 * np.log10(np.array([np.mean(x[i * h:i * h + w] ** 2) for i in range(frames)]) + 1e-12)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def slowdown_dropout(reference: np.ndarray, edited: np.ndarray, sample_rate: int, rate: float) -> dict[str, Any]:
|
|
326
|
+
"""
|
|
327
|
+
Where does the edit go quiet while the reference, warped through the speed change, does not? A big slow-down
|
|
328
|
+
can drop or smear a piece of the signal: the loudness (30 ms frames, level matched, small lag searched)
|
|
329
|
+
falls far below the reference at one spot. Reports the deepest dip in dB; only slow-downs below
|
|
330
|
+
DROPOUT_MAX_RATE are checked. Unvalidated beyond one vocal phrase, and a steep onset moved a few ms also dips.
|
|
331
|
+
"""
|
|
332
|
+
hop = 0.01
|
|
333
|
+
ref_env, edit_env = _envelope_db(reference, sample_rate, hop=hop), _envelope_db(edited, sample_rate, hop=hop)
|
|
334
|
+
if len(ref_env) < 10 or len(edit_env) < 10:
|
|
335
|
+
return {"verdict": "skipped", "reason": "too short for a loudness comparison"}
|
|
336
|
+
best: tuple[float, np.ndarray] | None = None
|
|
337
|
+
for lag in np.arange(-0.03, 0.0301, hop):
|
|
338
|
+
positions = ((np.arange(len(edit_env)) * hop * rate + lag) / hop).clip(0, len(ref_env) - 1)
|
|
339
|
+
warped = np.interp(positions, np.arange(len(ref_env)), ref_env)
|
|
340
|
+
active = warped > warped.max() - 30.0
|
|
341
|
+
if active.sum() < 10:
|
|
342
|
+
return {"verdict": "skipped", "reason": "too quiet for a loudness comparison"}
|
|
343
|
+
diff = (edit_env - warped)[active]
|
|
344
|
+
diff = diff - np.median(diff)
|
|
345
|
+
score = float(np.sqrt(np.mean(diff ** 2)))
|
|
346
|
+
if best is None or score < best[0]:
|
|
347
|
+
best = (score, diff)
|
|
348
|
+
dip = float(-best[1].min())
|
|
349
|
+
return {"verdict": "warn" if dip >= DROPOUT_WARN_DB else "ok", "deepestDipDb": round(dip, 1)}
|
|
350
|
+
|
|
351
|
+
|
|
315
352
|
def _click_verdict(edit_score: float | None, ref_score: float | None) -> str:
|
|
316
353
|
if edit_score is None:
|
|
317
354
|
return "unknown"
|
|
@@ -370,6 +407,8 @@ def verify_edit(reference: np.ndarray, edited: np.ndarray, sample_rate: int, *,
|
|
|
370
407
|
checks["pitch"] = pitch_drift(ref_mono, edit_mono, sample_rate, time_scale)
|
|
371
408
|
checks["tone"] = tone_difference(ref_mono, edit_mono, sample_rate, bool(checks["pitch"].get("varispeed")))
|
|
372
409
|
checks["transients"] = transient_change(ref_mono, edit_mono)
|
|
410
|
+
if time_scale < DROPOUT_MAX_RATE:
|
|
411
|
+
checks["dropout"] = slowdown_dropout(ref_mono, edit_mono, sample_rate, time_scale)
|
|
373
412
|
else:
|
|
374
413
|
null = compensated_null(reference, edited, sample_rate, max_lag_ms)
|
|
375
414
|
if "error" in null:
|