[ca55954] | 1 | from template import program_test_case |
---|
[031b1f9] | 2 | |
---|
[f1771f9] | 3 | class 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_with_inf_silence(self): |
---|
| 10 | """ test aubioonset with -s 0 """ |
---|
| 11 | self.command += " -s 0" |
---|
| 12 | self.getOutput() |
---|
| 13 | assert len(self.output) == 0, self.output |
---|
| 14 | |
---|
[ca55954] | 15 | class aubioonset_unit_finds_onset(aubioonset_unit): |
---|
| 16 | |
---|
| 17 | def test_aubioonset(self): |
---|
| 18 | """ test aubioonset with default parameters """ |
---|
| 19 | self.getOutput() |
---|
| 20 | assert len(str(self.output)) != 0, "no output produced with command:\n" \ |
---|
| 21 | + self.command |
---|
| 22 | |
---|
[031b1f9] | 23 | def test_aubioonset_with_no_silence(self): |
---|
| 24 | """ test aubioonset with -s -100 """ |
---|
| 25 | self.command += " -s -100 " |
---|
| 26 | self.getOutput() |
---|
| 27 | # only one onset in woodblock.aiff |
---|
[f1771f9] | 28 | self.assertNotEqual(0, len(str(self.output)), \ |
---|
| 29 | "no output produced with command:\n" + self.command) |
---|
| 30 | self.assertEqual(1, len(self.output.split('\n')) ) |
---|
[031b1f9] | 31 | # onset should be at 0.00000 |
---|
[f1771f9] | 32 | self.assertEqual(0, float(self.output.strip())) |
---|
| 33 | |
---|
| 34 | list_of_onset_modes = ["energy", "specdiff", "hfc", "complex", "phase", \ |
---|
| 35 | "kl", "mkl", "specflux"] |
---|
[031b1f9] | 36 | |
---|
[f1771f9] | 37 | for name in list_of_onset_modes: |
---|
| 38 | exec("class aubioonset_"+name+"_unit(aubioonset_unit):\n\ |
---|
[100f950] | 39 | options = \" -O "+name+" \"") |
---|
[9f9f63f] | 40 | |
---|
[100f950] | 41 | if __name__ == '__main__': unittest.main() |
---|