source: tests/python/examples/aubiopitch.py @ 685412e

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 685412e was d6f515d, checked in by Paul Brossier <piem@piem.org>, 17 years ago

added test for aubiopitch, using TwoCows?.wav from freesound

  • Property mode set to 100644
File size: 2.2 KB
Line 
1from template import *
2
3import os.path
4
5class aubiopitch_test_case(program_test_case):
6
7  import os.path
8  filename = os.path.join('..','..','sounds','woodblock.aiff')
9  progname = "PYTHONPATH=../../python:../../python/aubio/.libs " + \
10              os.path.join('..','..','python','aubiopitch')
11
12  def test_aubiopitch(self):
13    """ test aubiopitch with default parameters """
14    self.getOutput()
15    # FIXME: useless check
16    self.assertEqual(len(self.output.split('\n')), 1)
17    #self.assertEqual(float(self.output.strip()), 0.)
18
19  def test_aubiopitch_verbose(self):
20    """ test aubiopitch with -v parameter """
21    self.command += " -v "
22    self.getOutput()
23    # FIXME: loose checking: make sure at least 8 lines are printed
24    assert len(self.output) >= 8
25
26  def test_aubiopitch_devnull(self):
27    """ test aubiopitch on /dev/null """
28    self.filename = "/dev/null"
29    # exit status should not be 0
30    self.getOutput(expected_status = 256)
31    # and there should be an error message
32    assert len(self.output) > 0
33    # that looks like this
34    output_lines = self.output.split('\n')
35    #assert output_lines[0] == "Unable to open input file /dev/null."
36    #assert output_lines[1] == "Supported file format but file is malformed."
37    #assert output_lines[2] == "Could not open input file /dev/null."
38
39mode_names = ["yinfft", "yin", "fcomb", "mcomb", "schmitt"]
40for name in mode_names:
41  exec("class aubiopitch_test_case_" + name + "(aubiopitch_test_case):\n\
42    options = \" -m " + name + " \"")
43
44class aubiopitch_test_yinfft(program_test_case):
45
46  filename = os.path.join('..','..','sounds','16568_acclivity_TwoCows.wav')
47  progname = "PYTHONPATH=../../python:../../python/aubio/.libs " + \
48              os.path.join('..','..','python','aubiopitch')
49  options  = " -m yinfft -t 0.75 "
50
51  def test_aubiopitch(self):
52    """ test aubiopitch with default parameters """
53    self.getOutput()
54    expected_output = open(os.path.join('examples','aubiopitch','yinfft'+'.'+os.path.basename(self.filename)+'.txt')).read()
55    for line_out, line_exp in zip(self.output.split('\n'), expected_output.split('\n')):
56      assert line_out == line_exp, line_exp + " vs. " + line_out
57
58if __name__ == '__main__': unittest.main()
Note: See TracBrowser for help on using the repository browser.