justinsalamon / scaper

A library for soundscape synthesis and augmentation
BSD 3-Clause "New" or "Revised" License
377 stars 55 forks source link

Trim events using SoundFile. #128

Closed pseeth closed 4 years ago

pseeth commented 4 years ago

This PR makes it so that events are trimmed on read, rather than trimmed after. This is helpful for long source audio files.

This PR makes a change to the regression data. This was necessary because of the ordering of resampling vs trimming. In prior versions of Scaper, the order was:

  1. Read file from disk
  2. Resample it to new sampling rate
  3. Trim the resampled data

Now it's:

  1. Read file from disk, trimming it on read.
  2. Resample it.

So since the ordering changes, the output behavior changes. I updated the regression data to reflect this. Doing it this way will make it much faster when you have long source material (e.g. full length music stems). So the performance benefit is not apparent in the current profiling script but will be apparent when using Scaper with long source audio files.