source: tests/python/examples/aubioonset.py @ cc9d0cc

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

aubioonset.py tests: add specflux, use assertEqual

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[031b1f9]1from template import *
2
[f1771f9]3class aubioonset_unit(program_test_case):
[031b1f9]4 
5  import os.path
6  filename = os.path.join('..','..','sounds','woodblock.aiff')
7  progname = os.path.join('..','..','examples','aubioonset')
8
9  def test_aubioonset(self):
10    """ test aubioonset with default parameters """
11    self.getOutput()
[9f9f63f]12    assert len(str(self.output)) != 0, "no output produced with command:\n" \
13      + self.command
[031b1f9]14
15  def test_aubioonset_with_inf_silence(self):
16    """ test aubioonset with -s 0  """
17    self.command += " -s 0" 
18    self.getOutput()
19    assert len(self.output) == 0, self.output
20
21  def test_aubioonset_with_no_silence(self):
22    """ test aubioonset with -s -100 """ 
23    self.command += " -s -100 " 
24    self.getOutput()
25    # only one onset in woodblock.aiff
[f1771f9]26    self.assertNotEqual(0, len(str(self.output)), \
27      "no output produced with command:\n" + self.command)
28    self.assertEqual(1, len(self.output.split('\n')) )
[031b1f9]29    # onset should be at 0.00000
[f1771f9]30    self.assertEqual(0, float(self.output.strip()))
31
32list_of_onset_modes = ["energy", "specdiff", "hfc", "complex", "phase", \
33                      "kl", "mkl", "specflux"]
[031b1f9]34
[f1771f9]35for name in list_of_onset_modes:
36  exec("class aubioonset_"+name+"_unit(aubioonset_unit):\n\
[100f950]37  options = \" -O "+name+" \"")
[9f9f63f]38
[100f950]39if __name__ == '__main__': unittest.main()
Note: See TracBrowser for help on using the repository browser.