Store waveform peaks inline in audio_versions (JSONB columns) so WaveSurfer
can render the waveform immediately on page load without waiting for audio
decode. Adds a 100-point mini-waveform for version selector thumbnails.
Backend:
- Migration 0006: adds waveform_peaks and waveform_peaks_mini JSONB columns
- Worker generates both resolutions (500-pt full, 100-pt mini) during transcode
and stores them directly in DB — replaces file-based waveform_url approach
- AudioVersionRead schema exposes both fields inline (no extra HTTP round-trip)
- GET /versions/{id}/waveform reads from DB; adds ?resolution=mini support
Frontend:
- audioService.initialize() accepts peaks and calls ws.load(url, Float32Array)
so waveform renders instantly without audio decode
- useWaveform hook threads peaks option through to audioService
- PlayerPanel passes waveform_peaks from the active version to the hook
- New MiniWaveform SVG component (no WaveSurfer) renders mini peaks in the
version selector buttons
Fix: docker-compose.dev.yml now runs alembic upgrade head before starting
the API server, so a fresh volume gets the full schema automatically.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""Confirm that list_versions returns waveform_peaks inline (no extra request needed)."""
|
|
|
|
import uuid
|
|
from datetime import datetime, timezone
|
|
from unittest.mock import MagicMock
|
|
|
|
from rehearsalhub.db.models import AudioVersion
|
|
from rehearsalhub.schemas.audio_version import AudioVersionRead
|
|
|
|
|
|
def test_audio_version_read_includes_peaks_in_list_serialization():
|
|
"""AudioVersionRead (used by list_versions) serializes waveform_peaks inline."""
|
|
peaks = [0.1, 0.5, 0.9]
|
|
mini = [0.3, 0.7]
|
|
|
|
v = MagicMock(spec=AudioVersion)
|
|
v.id = uuid.uuid4()
|
|
v.song_id = uuid.uuid4()
|
|
v.version_number = 1
|
|
v.label = None
|
|
v.nc_file_path = "/test/v1.wav"
|
|
v.nc_file_etag = "etag"
|
|
v.cdn_hls_base = None
|
|
v.waveform_url = None
|
|
v.waveform_peaks = peaks
|
|
v.waveform_peaks_mini = mini
|
|
v.duration_ms = 3000
|
|
v.format = "wav"
|
|
v.file_size_bytes = 512
|
|
v.analysis_status = "done"
|
|
v.uploaded_by = None
|
|
v.uploaded_at = datetime.now(timezone.utc)
|
|
|
|
schema = AudioVersionRead.model_validate(v)
|
|
serialized = schema.model_dump()
|
|
|
|
assert serialized["waveform_peaks"] == peaks
|
|
assert serialized["waveform_peaks_mini"] == mini
|