- Timestamp:
- Jan 12, 2014, 4:28:49 AM (11 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:
- a4ec189
- Parents:
- aee840b
- Location:
- python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/aubio/slicing.py
raee840b r6f27719 38 38 remaining = next_stamp - total_frames 39 39 # not enough frames remaining, time to split 40 if remaining < =read:40 if remaining < read: 41 41 if remaining != 0: 42 42 # write remaining samples from current region … … 48 48 #print "new slice", total_frames, "+", remaining, "=", next_stamp 49 49 g = sink(new_sink_path, samplerate) 50 if remaining != read: 51 # write the remaining samples in the new file 52 g(vec[remaining:read], read - remaining) 50 # write the remaining samples in the new file 51 g(vec[remaining:read], read - remaining) 53 52 if len(timestamps): 54 53 next_stamp = int(timestamps.pop(0)) … … 60 59 if read < hopsize: break 61 60 61 # close the last file 62 62 del g -
python/tests/test_slicing.py
raee840b r6f27719 11 11 import shutil 12 12 13 n_slices = 8 14 13 15 class aubio_slicing_test_case(TestCase): 14 16 … … 18 20 19 21 def test_slice_start_only(self): 20 regions_start = [i*1000 for i in range( 100)]22 regions_start = [i*1000 for i in range(n_slices)] 21 23 slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir) 22 24 23 25 def test_slice_start_only_no_zero(self): 24 regions_start = [i*1000 for i in range(1, 100)]26 regions_start = [i*1000 for i in range(1, n_slices)] 25 27 slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir) 26 28 27 29 def test_slice_start_beyond_end(self): 28 regions_start = [i*1000 for i in range(1, 100)]30 regions_start = [i*1000 for i in range(1, n_slices)] 29 31 regions_start += [count_samples_in_file(self.source_file)] 30 32 regions_start += [count_samples_in_file(self.source_file) + 1000] … … 34 36 original_samples = count_samples_in_file(self.source_file) 35 37 written_samples = count_samples_in_directory(self.output_dir) 36 assert_equal( original_samples, written_samples,37 "number samples written different from number of original samples")38 assert_equal(written_samples, original_samples, 39 "number of samples written different from number of original samples") 38 40 shutil.rmtree(self.output_dir) 39 41 … … 79 81 original_samples = count_samples_in_file(self.source_file) 80 82 written_samples = count_samples_in_directory(self.output_dir) 81 assert_equal( original_samples, written_samples,82 "number samples written different from number of original samples")83 assert_equal(written_samples, original_samples, 84 "number of samples written different from number of original samples") 83 85 84 86 def tearDown(self):
Note: See TracChangeset
for help on using the changeset viewer.