92 lines
3.0 KiB
Python
92 lines
3.0 KiB
Python
"""
|
|
FIX para la conexion AbletonMCP - Implementa Fix A y Fix B de FIX.md
|
|
"""
|
|
import socket
|
|
import json
|
|
import time
|
|
|
|
def send_cmd(type_name, params=None, timeout=5):
|
|
params = params or {}
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
sock.settimeout(timeout)
|
|
try:
|
|
sock.connect(('127.0.0.1', 9877))
|
|
msg = json.dumps({'type': type_name, 'params': params}) + '\n'
|
|
sock.sendall(msg.encode())
|
|
data = b''
|
|
start = time.time()
|
|
while time.time() - start < timeout:
|
|
try:
|
|
chunk = sock.recv(8192)
|
|
if not chunk:
|
|
break
|
|
data += chunk
|
|
try:
|
|
return json.loads(data.decode())
|
|
except:
|
|
continue
|
|
except socket.timeout:
|
|
break
|
|
return json.loads(data.decode()) if data else None
|
|
except Exception as e:
|
|
return {'error': str(e)}
|
|
finally:
|
|
sock.close()
|
|
|
|
print('='*70)
|
|
print('DIAGNOSTICO Y FIX DE CONEXION ABLETONMCP')
|
|
print('='*70)
|
|
print()
|
|
|
|
# Paso 1: Verificar info de sesion
|
|
print('[1] Verificando get_session_info...')
|
|
result = send_cmd('get_session_info', {}, timeout=10)
|
|
print(f' Resultado: {json.dumps(result, indent=2)[:200]}...')
|
|
print()
|
|
|
|
if result and result.get('status') == 'success':
|
|
r = result.get('result', {})
|
|
tempo = r.get('bpm', 'N/A')
|
|
tracks = r.get('track_count', 'N/A')
|
|
print(f' [OK] Conexion funciona: BPM={tempo}, Tracks={tracks}')
|
|
|
|
# Verificar si los tracks tienen contenido real
|
|
print()
|
|
print('[2] Verificando tracks...')
|
|
has_real_content = False
|
|
for i in range(4):
|
|
track = send_cmd('get_track_info', {'track_index': i}, timeout=5)
|
|
if track and track.get('status') == 'success':
|
|
tr = track.get('result', {})
|
|
name = tr.get('name', '')
|
|
clips = tr.get('clip_count', 0)
|
|
if clips > 0:
|
|
has_real_content = True
|
|
print(f' Track {i}: {name} - {clips} clips [REAL]')
|
|
else:
|
|
print(f' Track {i}: {name} - {clips} clips [VACIO]')
|
|
|
|
print()
|
|
if has_real_content:
|
|
print('[OK] Ableton tiene contenido real - todo funciona!')
|
|
else:
|
|
print('[ALERTA] Ableton tiene 0 clips - los comandos no se ejecutaron realmente')
|
|
print()
|
|
print('SOLUCION (Fix B - Nueva sesion):')
|
|
print(' 1. En Ableton: File -> New Live Set')
|
|
print(' 2. Esperar 3 segundos')
|
|
print(' 3. El Remote Script se reinicia automaticamente')
|
|
print(' 4. Probar de nuevo con get_session_info()')
|
|
else:
|
|
print(' [ERROR] No hay respuesta de Ableton')
|
|
print()
|
|
print('SOLUCION (Fix C - Reinicio completo):')
|
|
print(' 1. Cerrar Ableton completamente')
|
|
print(' 2. Esperar 30 segundos')
|
|
print(' 3. Abrir Ableton nuevamente')
|
|
print(' 4. Verificar status bar: "AbletonMCP: Listening on port 9877"')
|
|
print(' 5. Correr start_server.bat')
|
|
|
|
print()
|
|
print('='*70)
|