Initial commit: RehearsalHub POC
Full-stack self-hosted band rehearsal platform: Backend (FastAPI + SQLAlchemy 2.0 async): - Auth with JWT (register, login, /me, settings) - Band management with Nextcloud folder integration - Song management with audio version tracking - Nextcloud scan to auto-import audio files - Band membership with link-based invite system - Song comments - Audio analysis worker (BPM, key, loudness, waveform) - Nextcloud activity watcher for auto-import - WebSocket support for real-time annotation updates - Alembic migrations (0001–0003) - Repository pattern, Ruff + mypy configured Frontend (React 18 + Vite + TypeScript strict): - Login/register page with post-login redirect - Home page with band list and creation form - Band page with member panel, invite link, song list, NC scan - Song page with waveform player, annotations, comment thread - Settings page for per-user Nextcloud credentials - Invite acceptance page (/invite/:token) - ESLint v9 flat config + TypeScript strict mode Infrastructure: - Docker Compose: PostgreSQL, Redis, API, worker, watcher, nginx - nginx reverse proxy for static files + /api/ proxy - make check runs all linters before docker compose build Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
49
worker/tests/test_waveform.py
Normal file
49
worker/tests/test_waveform.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""Tests for waveform peak extraction (no Essentia required)."""
|
||||
|
||||
import json
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from worker.pipeline.waveform import extract_peaks, generate_waveform_file, peaks_to_json
|
||||
|
||||
|
||||
def test_extract_peaks_returns_correct_length(sine_440hz):
|
||||
audio, sr = sine_440hz
|
||||
peaks = extract_peaks(audio, num_points=500)
|
||||
assert len(peaks) == 500
|
||||
|
||||
|
||||
def test_extract_peaks_normalized_between_0_and_1(sine_440hz):
|
||||
audio, sr = sine_440hz
|
||||
peaks = extract_peaks(audio, num_points=200)
|
||||
assert all(0.0 <= p <= 1.0 for p in peaks)
|
||||
assert max(peaks) == pytest.approx(1.0, abs=0.01)
|
||||
|
||||
|
||||
def test_extract_peaks_empty_audio():
|
||||
audio = np.array([], dtype=np.float32)
|
||||
peaks = extract_peaks(audio, num_points=100)
|
||||
assert len(peaks) == 100
|
||||
assert all(p == 0.0 for p in peaks)
|
||||
|
||||
|
||||
def test_peaks_to_json_valid_structure(sine_440hz):
|
||||
audio, _ = sine_440hz
|
||||
peaks = extract_peaks(audio)
|
||||
json_str = peaks_to_json(peaks)
|
||||
data = json.loads(json_str)
|
||||
assert data["version"] == 2
|
||||
assert data["channels"] == 1
|
||||
assert len(data["data"]) == len(peaks)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_generate_waveform_file_writes_json(tmp_path, sine_440hz):
|
||||
audio, _ = sine_440hz
|
||||
output = str(tmp_path / "waveform.json")
|
||||
await generate_waveform_file(audio, output)
|
||||
with open(output) as f:
|
||||
data = json.load(f)
|
||||
assert data["version"] == 2
|
||||
assert len(data["data"]) == 1000
|
||||
Reference in New Issue
Block a user