chore: initial commit
This commit is contained in:
31
choir-mixer/tests/conftest.py
Normal file
31
choir-mixer/tests/conftest.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
SAMPLE_RATE = 48000
|
||||
FRAME_DURATION_MS = 20
|
||||
SAMPLES_PER_FRAME = SAMPLE_RATE * FRAME_DURATION_MS // 1000 # 960
|
||||
|
||||
@pytest.fixture
|
||||
def silence():
|
||||
"""960 samples of silence."""
|
||||
return np.zeros(SAMPLES_PER_FRAME, dtype=np.float32)
|
||||
|
||||
@pytest.fixture
|
||||
def quiet_tone():
|
||||
"""960 samples of a quiet 440Hz sine wave at -40 dBFS."""
|
||||
t = np.arange(SAMPLES_PER_FRAME, dtype=np.float32) / SAMPLE_RATE
|
||||
amplitude = 10 ** (-40 / 20) # ~0.01
|
||||
return (amplitude * np.sin(2 * np.pi * 440 * t)).astype(np.float32)
|
||||
|
||||
@pytest.fixture
|
||||
def loud_tone():
|
||||
"""960 samples of a loud 440Hz sine wave at -6 dBFS."""
|
||||
t = np.arange(SAMPLES_PER_FRAME, dtype=np.float32) / SAMPLE_RATE
|
||||
amplitude = 10 ** (-6 / 20) # ~0.5
|
||||
return (amplitude * np.sin(2 * np.pi * 440 * t)).astype(np.float32)
|
||||
|
||||
@pytest.fixture
|
||||
def clipping_tone():
|
||||
"""960 samples of a sine wave that exceeds [-1, 1] range."""
|
||||
t = np.arange(SAMPLES_PER_FRAME, dtype=np.float32) / SAMPLE_RATE
|
||||
return (1.5 * np.sin(2 * np.pi * 440 * t)).astype(np.float32)
|
||||
Reference in New Issue
Block a user