Changeset 6f27719


Ignore:
Timestamp:
Jan 12, 2014, 4:28:49 AM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
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
Message:

python/lib/aubio/slicing.py: improve slicing, make tests faster

Location:
python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/slicing.py

    raee840b r6f27719  
    3838        remaining = next_stamp - total_frames
    3939        # not enough frames remaining, time to split
    40         if remaining <= read:
     40        if remaining < read:
    4141            if remaining != 0:
    4242                # write remaining samples from current region
     
    4848            #print "new slice", total_frames, "+", remaining, "=", next_stamp
    4949            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)
    5352            if len(timestamps):
    5453                next_stamp = int(timestamps.pop(0))
     
    6059        if read < hopsize: break
    6160
     61    # close the last file
    6262    del g
  • python/tests/test_slicing.py

    raee840b r6f27719  
    1111import shutil
    1212
     13n_slices = 8
     14
    1315class aubio_slicing_test_case(TestCase):
    1416
     
    1820
    1921    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)]
    2123        slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
    2224
    2325    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)]
    2527        slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
    2628
    2729    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)]
    2931        regions_start += [count_samples_in_file(self.source_file)]
    3032        regions_start += [count_samples_in_file(self.source_file) + 1000]
     
    3436        original_samples = count_samples_in_file(self.source_file)
    3537        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")
    3840        shutil.rmtree(self.output_dir)
    3941
     
    7981        original_samples = count_samples_in_file(self.source_file)
    8082        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")
    8385
    8486    def tearDown(self):
Note: See TracChangeset for help on using the changeset viewer.