source: python/tests/test_sink.py @ db1eab7

feature/autosinkfeature/constantqfeature/pitchshiftfeature/pydocstringsfeature/timestretchpitchshiftsamplertimestretchyinfft+
Last change on this file since db1eab7 was db1eab7, checked in by Paul Brossier <piem@piem.org>, 7 years ago

python/tests/test_sink.py: trigger sink bug

  • Property mode set to 100755
File size: 1.3 KB
Line 
1#! /usr/bin/env python
2
3from numpy.testing import TestCase, assert_equal, assert_almost_equal
4from aubio import fvec, source, sink
5from numpy import array
6from utils import list_all_sounds
7
8list_of_sounds = list_all_sounds('sounds')
9path = None
10
11class aubio_sink_test_case(TestCase):
12
13    def setUp(self):
14        if not len(list_of_sounds): self.skipTest('add some sound files in \'python/tests/sounds\'')
15
16    def test_read(self):
17        for path in list_of_sounds:
18            for samplerate, hop_size in zip([0, 44100, 8000, 32000], [512, 1024, 64, 256]):
19                f = source(path, samplerate, hop_size)
20                if samplerate == 0: samplerate = f.samplerate
21                g = sink('/tmp/f.wav', samplerate)
22                total_frames = 0
23                while True:
24                    vec, read = f()
25                    g(vec, read)
26                    total_frames += read
27                    if read < f.hop_size: break
28                print "read", "%.2fs" % (total_frames / float(f.samplerate) ),
29                print "(", total_frames, "frames", "in",
30                print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
31                print "from", f.uri,
32                print "to", g.uri
33
34if __name__ == '__main__':
35  from unittest import main
36  main()
37
Note: See TracBrowser for help on using the repository browser.