mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Implemented beatgrid controls
This commit is contained in:
1 parent
14f5bf3774
commit
815b700075
8 files changed
+457
-23
No files matched your search
@@ -25,6 +25,7 @@ from .schemas import (
|
||||
FileTagOutcome,
|
||||
FsEntry,
|
||||
FsListing,
|
||||
GridEdit,
|
||||
OpenCollection,
|
||||
PlaylistNode,
|
||||
RenamePlaylist,
|
||||
@@ -32,6 +33,7 @@ from .schemas import (
|
||||
SetEntries,
|
||||
SetHotcue,
|
||||
SetHotcueType,
|
||||
SetLock,
|
||||
Stats,
|
||||
Track,
|
||||
TrackCues,
|
||||
@@ -355,7 +357,9 @@ def _build_track_cues(entry) -> TrackCues:
|
||||
)
|
||||
)
|
||||
bpm = grid_bpm if grid_bpm is not None else (entry.tempo.bpm if entry.tempo else None)
|
||||
return TrackCues(bpm=bpm, grid_anchor=grid_anchor, cues=cues)
|
||||
return TrackCues(
|
||||
bpm=bpm, grid_anchor=grid_anchor, locked=bool(entry.lock), cues=cues
|
||||
)
|
||||
|
||||
|
||||
def _cues_for(track_id: str) -> TrackCues:
|
||||
@@ -412,6 +416,36 @@ def delete_hotcue(track_id: str, slot: int) -> TrackCues:
|
||||
return _sync_cue_edit(track_id)
|
||||
|
||||
|
||||
@app.patch("/api/tracks/grid", response_model=TrackCues)
|
||||
def edit_grid(body: GridEdit) -> TrackCues:
|
||||
"""Set the beatgrid BPM and/or move the grid marker (beat 1)."""
|
||||
try:
|
||||
require_store().set_grid(body.track_id, body.bpm, body.anchor)
|
||||
except PlaylistError as ex:
|
||||
raise HTTPException(400, str(ex))
|
||||
return _sync_cue_edit(body.track_id)
|
||||
|
||||
|
||||
@app.delete("/api/tracks/grid", response_model=TrackCues)
|
||||
def remove_grid(track_id: str) -> TrackCues:
|
||||
"""Delete the track's grid marker(s)."""
|
||||
try:
|
||||
require_store().delete_grid(track_id)
|
||||
except PlaylistError as ex:
|
||||
raise HTTPException(400, str(ex))
|
||||
return _sync_cue_edit(track_id)
|
||||
|
||||
|
||||
@app.patch("/api/tracks/lock", response_model=TrackCues)
|
||||
def edit_lock(body: SetLock) -> TrackCues:
|
||||
"""Toggle Traktor's LOCK flag on a track."""
|
||||
try:
|
||||
require_store().set_lock(body.track_id, body.locked)
|
||||
except PlaylistError as ex:
|
||||
raise HTTPException(400, str(ex))
|
||||
return _sync_cue_edit(body.track_id)
|
||||
|
||||
|
||||
@app.put("/api/tracks/art")
|
||||
async def set_track_art(track_id: str = Form(...), file: UploadFile = File(...)) -> dict:
|
||||
"""Stage replacement cover art for a track (written to the file on save)."""
|
||||
|
||||
Reference in new issue
Block a user