fix: piano roll tab có thể play với soundfont

This commit is contained in:
2026-07-23 20:34:52 +07:00
parent a21266736c
commit dac661e6c6
8 changed files with 460 additions and 134 deletions
+11 -1
View File
@@ -47,10 +47,20 @@ async def upload_soundfont(
if not PluginManager.validate_sf2_header(contents):
raise HTTPException(status_code=400, detail="Invalid SoundFont file: missing RIFF/sfbk header")
file_id = str(uuid.uuid4()) + os.path.splitext(file.filename)[1]
file_ext = os.path.splitext(file.filename)[1]
file_uuid = str(uuid.uuid4())
# Store original name in a sidecar file
base_name = os.path.splitext(file.filename)[0].replace('/', '_').replace('\\', '_')
file_id = file_uuid + file_ext
dest_path = os.path.join(UPLOAD_SF_DIR, file_id)
with open(dest_path, "wb") as f:
f.write(contents)
# Save metadata with original name
meta_path = os.path.join(UPLOAD_SF_DIR, file_uuid + ".meta")
with open(meta_path, "w", encoding="utf-8") as f:
import json
json.dump({"original_name": file.filename, "uuid": file_uuid, "file": file_id}, f)
return {"id": file_id, "name": file.filename, "path": dest_path, "size_bytes": len(contents)}