import sys, os, warnings
warnings.filterwarnings("ignore")
sys.path.insert(0, r"C:\Users\Administrator\Documents\fl_control")
from src.selector import SampleSelector

sel = SampleSelector()

print("=== KICKS at 95 BPM ===")
for m in sel.select(role="kick", bpm=95, limit=5):
    s = m.sample
    nm = s["new_name"]
    ky = s["musical"]["key"]
    bp = s["perceptual"]["tempo"]
    ch = s["character"]
    bd = m.score_breakdown
    print(f"  {m.score:.2f} {nm:45s} key={ky:5s} bpm={bp:5.0f} char={ch:10s} | role={bd.get('role',0):.1f} key={bd.get('key',0):.2f} bpm={bd.get('bpm',0):.2f} char={bd.get('character',0):.2f}")

print("\n=== BASS in Am at 92 BPM ===")
for m in sel.select(role="bass", key="Am", bpm=92, limit=5):
    s = m.sample
    nm = s["new_name"]
    ky = s["musical"]["key"]
    bp = s["perceptual"]["tempo"]
    ch = s["character"]
    print(f"  {m.score:.2f} {nm:45s} key={ky:5s} bpm={bp:5.0f} char={ch}")

print("\n=== PAD in C#m ===")
for m in sel.select(role="pad", key="C#m", limit=5):
    s = m.sample
    print(f"  {m.score:.2f} {s['new_name']:45s} key={s['musical']['key']:5s} char={s['character']}")

print("\n=== LEAD warm at 95 BPM in Am ===")
for m in sel.select(role="lead", key="Am", bpm=95, character="warm", limit=5):
    s = m.sample
    print(f"  {m.score:.2f} {s['new_name']:45s} key={s['musical']['key']:5s} bpm={s['perceptual']['tempo']:5.0f} char={s['character']}")

print("\n=== VOCAL in Cm ===")
for m in sel.select(role="vocal", key="Cm", limit=5):
    s = m.sample
    print(f"  {m.score:.2f} {s['new_name']:45s} key={s['musical']['key']:5s} char={s['character']}")

print(f"\nStats: {sel.get_stats()}")
