Changeset ca1abdd for tests/python/src/pitch
- Timestamp:
- Oct 19, 2009, 10:51:59 AM (15 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- b14107f
- Parents:
- 9f07d52
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/python/src/pitch/pitchdetection.py
r9f07d52 rca1abdd 7 7 samplerate = 44100. 8 8 9 class pitch detection_test_case(unittest.TestCase):9 class pitch_test_case(unittest.TestCase): 10 10 11 11 def setUp(self, type = aubio_pitch_yinfft, mode = aubio_pitchm_freq): … … 15 15 mode = aubio_pitchm_freq): 16 16 self.type = type 17 self.o = new_aubio_pitch detection(buf_size, hop_size,17 self.o = new_aubio_pitch(buf_size, hop_size, 18 18 channels, int(samplerate), type, mode) 19 19 20 20 def tearDown(self): 21 del_aubio_pitch detection(self.o)21 del_aubio_pitch(self.o) 22 22 23 def test_pitch detection(self):24 """ create and delete pitch detection"""23 def test_pitch(self): 24 """ create and delete pitch """ 25 25 pass 26 26 27 def test_pitch detection_run_zeroes(self):28 """ run pitch detectionon an empty buffer """27 def test_pitch_run_zeroes(self): 28 """ run pitch on an empty buffer """ 29 29 vec = new_fvec(buf_size, channels) 30 30 out = new_fvec(1, channels) 31 31 for i in range(100): 32 aubio_pitch detection_do(self.o,vec, out)32 aubio_pitch_do(self.o,vec, out) 33 33 self.assertEqual(fvec_read_sample(out, 0, 0),0.) 34 34 del vec 35 35 36 def test_pitch detection_run_4_impulses(self):37 """ run pitch detectionon a train of 4 impulses """36 def test_pitch_run_4_impulses(self): 37 """ run pitch on a train of 4 impulses """ 38 38 vec = new_fvec(buf_size, channels) 39 39 out = new_fvec(1, channels) … … 44 44 frequency = samplerate/2*4/buf_size 45 45 for i in range(100): 46 aubio_pitch detection_do(self.o,vec, out)46 aubio_pitch_do(self.o,vec, out) 47 47 self.assertEqual(fvec_read_sample(out, 0, 0),frequency) 48 48 del vec 49 49 50 def test_pitch detection_run_4_positive_impulses(self):51 """ run pitch detectionon a train of 4 positive impulses of arbitrary size """50 def test_pitch_run_4_positive_impulses(self): 51 """ run pitch on a train of 4 positive impulses of arbitrary size """ 52 52 vec = new_fvec(buf_size, channels) 53 53 out = new_fvec(1, channels) … … 58 58 fvec_write_sample(vec, 2.-.01*i,0, buf_size/2) 59 59 fvec_write_sample(vec, 2.-.01*i,0,3*buf_size/4) 60 aubio_pitch detection_do(self.o,vec, out)60 aubio_pitch_do(self.o,vec, out) 61 61 self.assertAlmostEqual(fvec_read_sample(out, 0, 0),frequency,1) 62 62 del vec 63 63 64 def test_pitch detection_run_4_negative_impulses(self):65 """ run pitch detectionon a train of 4 negative impulses of arbitrary size """64 def test_pitch_run_4_negative_impulses(self): 65 """ run pitch on a train of 4 negative impulses of arbitrary size """ 66 66 vec = new_fvec(buf_size, channels) 67 67 out = new_fvec(1, channels) … … 72 72 fvec_write_sample(vec,-.01*i,0, buf_size/2) 73 73 fvec_write_sample(vec,-.01*i,0,3*buf_size/4) 74 aubio_pitch detection_do(self.o,vec, out)74 aubio_pitch_do(self.o,vec, out) 75 75 self.assertAlmostEqual(fvec_read_sample(out, 0, 0),frequency,1) 76 76 del vec 77 77 78 def test_pitch detection_run_8_impulses(self):79 """ run pitch detectionon a train of 8 impulses """78 def test_pitch_run_8_impulses(self): 79 """ run pitch on a train of 8 impulses """ 80 80 vec = new_fvec(buf_size, channels) 81 81 out = new_fvec(1, channels) … … 89 89 fvec_write_sample(vec,-1.,0,7*buf_size/8) 90 90 for i in range(100): 91 aubio_pitch detection_do(self.o,vec, out)91 aubio_pitch_do(self.o,vec, out) 92 92 self.assertAlmostEqual(fvec_read_sample(out, 0, 0), 93 93 samplerate/2/buf_size*8, 1) … … 95 95 96 96 """ 97 class pitch detection_yin_test_case(pitchdetection_test_case):97 class pitch_yin_test_case(pitchdetection_test_case): 98 98 def setUp(self, type = aubio_pitch_yin): 99 99 self.create(type=type) 100 100 101 class pitch detection_fcomb_test_case(pitchdetection_test_case):101 class pitch_fcomb_test_case(pitchdetection_test_case): 102 102 def setUp(self, type = aubio_pitch_fcomb): 103 103 self.create(type=type) 104 104 105 class pitch detection_mcomb_test_case(pitchdetection_test_case):105 class pitch_mcomb_test_case(pitchdetection_test_case): 106 106 def setUp(self, type = aubio_pitch_mcomb): 107 107 self.create(type=type) 108 108 109 class pitch detection_schmitt_test_case(pitchdetection_test_case):109 class pitch_schmitt_test_case(pitchdetection_test_case): 110 110 def setUp(self, type = aubio_pitch_schmitt): 111 111 self.create(type=type)
Note: See TracChangeset
for help on using the changeset viewer.