Skip to content

Commit

Permalink
pianoroll unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yiitozer committed Mar 12, 2024
1 parent 211c609 commit 6a72f24
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
1 change: 0 additions & 1 deletion tests/test_chroma.py

This file was deleted.

39 changes: 35 additions & 4 deletions tests/test_pianoroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,45 @@

Fs = 22050
SAMPLE, _ = sf.read('data_audio/samples/01Pia1F060f_np___0_short.wav', Fs)
DF_PIANOROLL = pd.read_csv('data_csv/demo_pianoroll/FMP_B_Sonify_Pitch_Schubert_D911-11_SC06.csv',
sep=';')
PARTIALS = [np.array([1]), np.array([1, 2, 3])]
PARTIALS_AMPLITUDES = [np.array([1]), np.array([1, 0.5, 0.25])]


def test_pianoroll_additive():
for partial_idx, partials in enumerate(PARTIALS):
y = sonify_pianoroll_additive_synthesis(pianoroll_df=DF_PIANOROLL,
partials=partials,
partials_amplitudes=PARTIALS_AMPLITUDES[partial_idx],
sonification_duration=5.0)

ref, _ = sf.read(f'tests/data/pianoroll_add_{partial_idx}.wav')
assert np.allclose(y, ref, atol=1e-4, rtol=1e-5)


def test_pianoroll_sample():
pass
y = sonify_pianoroll_sample(pianoroll_df=DF_PIANOROLL,
sample=SAMPLE,
reference_pitch=60,
sonification_duration=3.0)
ref, _ = sf.read(f'tests/data/pianoroll_sample.wav')
assert np.allclose(y, ref, atol=1e-4, rtol=1e-5)


def test_pianoroll_fm():
pass
y = sonify_pianoroll_fm_synthesis(pianoroll_df=DF_PIANOROLL,
sonification_duration=3.0,
mod_rate_relative=0.5,
mod_amp=0.1)

ref, _ = sf.read(f'tests/data/pianoroll_fm.wav')
assert np.allclose(y, ref, atol=1e-4, rtol=1e-5)

def test_pianoroll_additive():

def test_pianoroll_clicks():
pass
y = sonify_pianoroll_clicks(pianoroll_df=DF_PIANOROLL,
sonification_duration=3.0)

ref, _ = sf.read(f'tests/data/pianoroll_clicks.wav')
assert np.allclose(y, ref, atol=1e-4, rtol=1e-5)
Empty file removed tests/test_spectrogram.py
Empty file.
4 changes: 0 additions & 4 deletions tests/test_tse.py

This file was deleted.

0 comments on commit 6a72f24

Please sign in to comment.