|
|
|
@ -1,11 +1,22 @@
|
|
|
|
|
"""Test Setup."""
|
|
|
|
|
import unittest
|
|
|
|
|
import numpy as np
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestSetup(unittest.TestCase):
|
|
|
|
|
# test the installation of libsndfile library
|
|
|
|
|
def test_soundfile(self):
|
|
|
|
|
import soundfile
|
|
|
|
|
import soundfile as sf
|
|
|
|
|
# floating point data is typically limited to the interval [-1.0, 1.0],
|
|
|
|
|
# but smaller/larger values are supported as well
|
|
|
|
|
data = np.array([[1.75, -1.75], [1.0, -1.0], [0.5, -0.5],
|
|
|
|
|
[0.25, -0.25]])
|
|
|
|
|
file = 'test.wav'
|
|
|
|
|
sf.write(file, data, 44100, format='WAV', subtype='FLOAT')
|
|
|
|
|
read, fs = sf.read(file)
|
|
|
|
|
assert np.all(read == data)
|
|
|
|
|
assert fs == 44100
|
|
|
|
|
os.remove(file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|