Ignore:
File:
1 edited

Legend:

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

    rc9c012e rdc654f8  
    77
    88def slice_source_at_stamps(source_file, timestamps, timestamps_end=None,
    9                            output_dir=None, samplerate=0, hopsize=256,
    10                            create_first=False):
     9                           output_dir=None, samplerate=0, hopsize=256):
    1110    """ slice a sound file at given timestamps """
    1211
     
    1413        raise ValueError("no timestamps given")
    1514
    16     if timestamps[0] != 0 and create_first:
     15    if timestamps[0] != 0:
    1716        timestamps = [0] + timestamps
    1817        if timestamps_end is not None:
     
    2019
    2120    if timestamps_end is not None:
    22         if len(timestamps_end) == len(timestamps) - 1:
    23             timestamps_end = timestamps_end + [_max_timestamp]
    24         elif len(timestamps_end) != len(timestamps):
     21        if len(timestamps_end) != len(timestamps):
    2522            raise ValueError("len(timestamps_end) != len(timestamps)")
    2623    else:
     
    5249        vec, read = _source.do_multi()
    5350        # if the total number of frames read will exceed the next region start
    54         while len(regions) and total_frames + read >= regions[0][0]:
     51        if len(regions) and total_frames + read >= regions[0][0]:
    5552            #print "getting", regions[0], "at", total_frames
    5653            # get next region
     
    7976                    # write remaining samples from current region
    8077                    _sink.do_multi(vec[:, start:remaining], remaining - start)
    81                     #print("closing region", "remaining", remaining)
     78                    #print "closing region", "remaining", remaining
    8279                    # close this file
    8380                    _sink.close()
     
    8683                _sink.do_multi(vec[:, start:read], read - start)
    8784        total_frames += read
    88         # remove old slices
    89         slices = list(filter(lambda s: s['end_stamp'] > total_frames,
    90             slices))
    9185        if read < hopsize:
    9286            break
Note: See TracChangeset for help on using the changeset viewer.