test(chord): retry dropped RTT reads in the fixed-key voicing check
STRING_OK lines are sometimes lost under load. Resend the string command until the note comes back. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
605af8f045
commit
9089c9994a
|
|
@ -37,7 +37,8 @@ CASES = [
|
||||||
("G", 7, 10, "C", (43, 48, 52, 55, 60, 64)),
|
("G", 7, 10, "C", (43, 48, 52, 55, 60, 64)),
|
||||||
("G", 7, 13, "D", (42, 45, 50, 57, 62, 66)),
|
("G", 7, 13, "D", (42, 45, 50, 57, 62, 66)),
|
||||||
("G", 7, 16, "Em", (40, 47, 52, 55, 59, 64)),
|
("G", 7, 16, "Em", (40, 47, 52, 55, 59, 64)),
|
||||||
("G", 7, 19, "#Fm", (42, 49, 54, 58, 61, 66)),
|
# 键 19 出厂是小三:C 调 IV 的 Fm 行再 +1
|
||||||
|
("G", 7, 19, "#Fm", (42, 49, 54, 57, 61, 66)),
|
||||||
# D I = C 调 II 行;F# I = F 调 I 行全体 +1
|
# D I = C 调 II 行;F# I = F 调 I 行全体 +1
|
||||||
("D", 2, 1, "D", (42, 45, 50, 57, 62, 66)),
|
("D", 2, 1, "D", (42, 45, 50, 57, 62, 66)),
|
||||||
("F#", 6, 1, "F#", (42, 49, 54, 58, 61, 66)),
|
("F#", 6, 1, "F#", (42, 49, 54, 58, 61, 66)),
|
||||||
|
|
@ -55,8 +56,9 @@ def last_string_note(text: str, string_n: int) -> int | None:
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
fails = 0
|
fails = 0
|
||||||
print("=== 固定调六弦音高 RTT ===", flush=True)
|
print("=== 固定调六弦音高 RTT ===", flush=True)
|
||||||
with open_session(reset=False) as sess:
|
with open_session(reset=True) as sess:
|
||||||
sess.cmd("tone pick f", settle=1.0)
|
sess.cmd("tone pick f", settle=1.0)
|
||||||
|
sess.cmd("log level E", settle=0.3)
|
||||||
sess.cmd("chord key 23", settle=0.3)
|
sess.cmd("chord key 23", settle=0.3)
|
||||||
sess.cmd("chord key 0", settle=0.2)
|
sess.cmd("chord key 0", settle=0.2)
|
||||||
cur_xp = None
|
cur_xp = None
|
||||||
|
|
@ -69,10 +71,19 @@ def main() -> int:
|
||||||
print(f"\n-- {key_name} {chord} key={key} xp={xp}", flush=True)
|
print(f"\n-- {key_name} {chord} key={key} xp={xp}", flush=True)
|
||||||
for s in range(6, 0, -1):
|
for s in range(6, 0, -1):
|
||||||
expect = int(notes[6 - s])
|
expect = int(notes[6 - s])
|
||||||
n0 = len(sess.lines)
|
got = None
|
||||||
sess.cmd(f"string {s}", settle=0.12)
|
for _try in range(4):
|
||||||
sess.cmd(f"string {s} off", settle=0.05)
|
n0 = len(sess.lines)
|
||||||
got = last_string_note("\n".join(sess.lines[n0:]), s)
|
sess.cmd(f"string {s}", settle=0.02)
|
||||||
|
deadline = time.monotonic() + 0.6
|
||||||
|
while time.monotonic() < deadline:
|
||||||
|
got = last_string_note("\n".join(sess.lines[n0:]), s)
|
||||||
|
if got is not None:
|
||||||
|
break
|
||||||
|
sess.pump(0.04)
|
||||||
|
if got is not None:
|
||||||
|
break
|
||||||
|
sess.cmd(f"string {s} off", settle=0.02)
|
||||||
ok = got == expect
|
ok = got == expect
|
||||||
if not ok:
|
if not ok:
|
||||||
fails += 1
|
fails += 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue