Browse Source

Support FLAC

sample-track
Ben Niemann 2 years ago
parent
commit
70c06f6903
  1. 1
      noisicaa/builtin_nodes/sample_track/model.py
  2. 9
      noisicaa/builtin_nodes/sample_track/model_test.py

1
noisicaa/builtin_nodes/sample_track/model.py

@ -146,6 +146,7 @@ class SampleReader(object):
class SndFileReader(SampleReader):
mime_types = {
'audio/x-wav',
'audio/x-flac',
}
def __init__(self, path: str) -> None:

9
noisicaa/builtin_nodes/sample_track/model_test.py

@ -157,6 +157,15 @@ class SampleTrackTest(base_track_test.TrackTestMixin, unittest.AsyncTestCase):
self.assertEqual(loaded_sample.sample_rate, 44100)
self.assertEqual(len(loaded_sample.raw_paths), 2)
async def test_load_sample_flac(self):
path = os.path.join(unittest.TESTDATA_DIR, 'future-thunder1.flac')
track = await self._add_track()
loaded_sample = await track.load_sample(path, self.loop)
self.assertEqual(loaded_sample.path, path)
self.assertEqual(loaded_sample.num_samples, 126208)
self.assertEqual(loaded_sample.sample_rate, 44100)
self.assertEqual(len(loaded_sample.raw_paths), 2)
async def test_load_sample_mp3(self):
path = os.path.join(unittest.TESTDATA_DIR, 'future-thunder1.mp3')
track = await self._add_track()

Loading…
Cancel
Save