Showing the changes to python/scripts (1 of 1 file). Show all
Unified · Split
| @@ -173,24 +173,24 @@ if __name__ == '__main__': · 172 unmodified lines | |||
| 173 | g = sink(new_sink_name(source_base_name, 0.), samplerate) | 173 | g = sink(new_sink_name(source_base_name, 0.), samplerate) |
| 174 | total_frames = 0 | 174 | total_frames = 0 |
| 175 | # get next region | 175 | # get next region |
| 176 | next_onset = int(timestamps.pop(0)) | 176 | next_stamp = int(timestamps.pop(0)) |
| 177 | while True: | 177 | while True: |
| 178 | vec, read = s() | 178 | vec, read = s() |
| 179 | remaining = next_onset - total_frames | 179 | remaining = next_stamp - total_frames |
| 180 | if remaining <= read: | 180 | if remaining <= read: |
| 181 | # write remaining samples from current region | 181 | # write remaining samples from current region |
| 182 | g(vec[0:remaining], remaining) | 182 | g(vec[0:remaining], remaining) |
| 183 | # close this file | 183 | # close this file |
| 184 | del g | 184 | del g |
| 185 | # create a new file for the new region | 185 | # create a new file for the new region |
| 186 | g = sink(new_sink_name(source_base_name, next_onset / float(samplerate)), samplerate) | 186 | g = sink(new_sink_name(source_base_name, next_stamp / float(samplerate)), samplerate) |
| 187 | # write the remaining samples in the new file | 187 | # write the remaining samples in the new file |
| 188 | g(vec[remaining:read], read - remaining) | 188 | g(vec[remaining:read], read - remaining) |
| 189 | #print "new slice", total_frames_written, "+", remaining, "=", start_of_next_region | 189 | #print "new slice", total_frames_written, "+", remaining, "=", start_of_next_region |
| 190 | if len(timestamps): | 190 | if len(timestamps): |
| 191 | next_onset = int(timestamps.pop(0)) | 191 | next_stamp = int(timestamps.pop(0)) |
| 192 | else: | 192 | else: |
| 193 | next_onset = 1e120 | 193 | next_stamp = 1e120 |
| 194 | else: | 194 | else: |
| 195 | g(vec[0:read], read) | 195 | g(vec[0:read], read) |
| 196 | total_frames += read | 196 | total_frames += read |