def _cut_slice(options, timestamps): # cutting pass nstamps = len(timestamps) if nstamps > 0: # generate output files timestamps_end = None if options.cut_every_nslices: timestamps = timestamps[::options.cut_every_nslices] nstamps = len(timestamps) if options.cut_until_nslices and options.cut_until_nsamples: msg = "using cut_until_nslices, but cut_until_nsamples is set" warnings.warn(msg) if options.cut_until_nsamples: lag = options.cut_until_nsamples timestamps_end = [t + lag for t in timestamps[1:]] timestamps_end += [1e120] if options.cut_until_nslices: slice_lag = options.cut_until_nslices timestamps_end = [t for t in timestamps[1 + slice_lag:]] timestamps_end += [1e120] * (options.cut_until_nslices + 1) aubio.slice_source_at_stamps(options.source_uri, timestamps, timestamps_end = timestamps_end, output_dir = options.output_directory, samplerate = options.samplerate, create_first = options.create_first)
def test_slice_start_every_blocksize(self): hopsize = 200 regions_start = [i * hopsize for i in range(1, n_slices)] slice_source_at_stamps(self.source_file, regions_start, output_dir=self.output_dir, hopsize=200)
def _cut_slice(options, timestamps): # cutting pass nstamps = len(timestamps) if nstamps > 0: # generate output files timestamps_end = None if options.cut_every_nslices: timestamps = timestamps[::options.cut_every_nslices] nstamps = len(timestamps) if options.cut_until_nslices and options.cut_until_nsamples: msg = "using cut_until_nslices, but cut_until_nsamples is set" warnings.warn(msg) if options.cut_until_nsamples: lag = options.cut_until_nsamples timestamps_end = [t + lag for t in timestamps[1:]] timestamps_end += [1e120] if options.cut_until_nslices: slice_lag = options.cut_until_nslices timestamps_end = [t for t in timestamps[1 + slice_lag:]] timestamps_end += [1e120] * (options.cut_until_nslices + 1) aubio.slice_source_at_stamps(options.source_uri, timestamps, timestamps_end=timestamps_end, output_dir=options.output_directory, samplerate=options.samplerate, create_first=options.create_first)
def test_slice_start_beyond_end(self): regions_start = [i * 1000 for i in range(1, n_slices)] regions_start += [count_samples_in_file(self.source_file) + 1000] slice_source_at_stamps(self.source_file, regions_start, output_dir=self.output_dir, create_first=True)
def test_slice_start_and_ends_overlaping(self): regions_start = [i*1000 for i in range(n_slices)] regions_ends = [start + 1199 for start in regions_start] slice_source_at_stamps(self.source_file, regions_start, regions_ends, output_dir = self.output_dir) expected_samples = 1200 * n_slices written_samples = count_samples_in_directory(self.output_dir) total_files = count_files_in_directory(self.output_dir) assert_equal(n_slices, total_files, "number of slices created different from expected") assert_equal(written_samples, expected_samples, "number of samples written different from number of original samples")
def test_slice_start_and_ends_no_gap(self): regions_start = [i*1000 for i in range(n_slices)] regions_ends = [start - 1 for start in regions_start[1:]] + [1e120] slice_source_at_stamps(self.source_file, regions_start, regions_ends, output_dir = self.output_dir) original_samples = count_samples_in_file(self.source_file) written_samples = count_samples_in_directory(self.output_dir) total_files = count_files_in_directory(self.output_dir) assert_equal(n_slices, total_files, "number of slices created different from expected") assert_equal(written_samples, original_samples, "number of samples written different from number of original samples")
def test_slice_no_ends(self): regions_start = [i*1000 for i in range(1, n_slices)] regions_end = None slice_source_at_stamps (self.source_file, regions_start, regions_end, output_dir = self.output_dir) total_files = count_files_in_directory(self.output_dir) assert_equal(n_slices, total_files, "number of slices created different from expected") original_samples = count_samples_in_file(self.source_file) written_samples = count_samples_in_directory(self.output_dir) assert_equal(written_samples, original_samples, "number of samples written different from number of original samples")
def test_slice_start_only_no_zero(self): regions_start = [i * 1000 for i in range(1, n_slices)] slice_source_at_stamps(self.source_file, regions_start, output_dir=self.output_dir)
def test_slice_start_every_blocksize(self): hopsize = 200 regions_start = [i*hopsize for i in range(1, n_slices)] slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir, hopsize = 200)
def test_slice_start_beyond_end(self): regions_start = [i*1000 for i in range(1, n_slices)] regions_start += [count_samples_in_file(self.source_file) + 1000] slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
def test_slice_start_only_no_zero(self): regions_start = [i*1000 for i in range(1, n_slices)] slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)