import sys, os, warnings
warnings.filterwarnings('ignore')
sys.path.insert(0, r'C:\Users\Administrator\Documents\fl_control')
os.chdir(r'C:\Users\Administrator\Documents\fl_control')
from src.analyzer import analyze_file

tests = [
    ('KICK', r'libreria\reggaeton\kick\kick nes 1.wav'),
    ('SNARE', r'libreria\reggaeton\snare\snare nes 1.wav'),
    ('HIHAT', r'librerias\reggaeton\reggaeton 2\hi-hat (para percs normalmente)\hi-hat 1.wav'),
    ('BASS', r'librerias\reggaeton\3. ONE SHOTS\Bass Reventado (c) @dastin.prod.wav'),
    ('DRUMLOOP', r'librerias\reggaeton\4. DRUM LOOPS\LOOP 2 90bpm @dastin.prod.wav'),
    ('FX', r'libreria\reggaeton\fx\impact.wav'),
    ('PERC', r'librerias\reggaeton\10. PERCS\PERC 1 @dastin.prod.wav'),
    ('VOCAL', r'librerias\reggaeton\11. VOCALS\AAA.wav'),
]

for label, path in tests:
    full = os.path.join(r'C:\Users\Administrator\Documents\fl_control', path)
    if not os.path.exists(full):
        print(f'{label}: FILE NOT FOUND - {path}')
        continue
    r = analyze_file(full)
    if r and 'error' not in r:
        role = r['role']
        char = r['character']
        key = r['musical']['key']
        bpm = r['perceptual']['tempo']
        lufs = r['perceptual']['lufs']
        dur = r['signal']['duration']
        new = r['new_name']
        print(f'{label:10s} -> role={role:10s} char={char:12s} key={key:5s} bpm={bpm:6.1f} lufs={lufs:6.1f} dur={dur:6.3f}')
        print(f'           new: {new}')
    else:
        print(f'{label}: ERROR - {r}')
