+std::vector<float> crop(const std::vector<float>& pcm, float crop_start, float crop_end, int sample_rate)
+{
+ size_t start_sample, end_sample;
+ if (crop_start >= 0.0f) {
+ start_sample = std::min<size_t>(lrintf(crop_start * sample_rate), pcm.size());
+ }
+ if (crop_end >= 0.0f) {
+ end_sample = std::min<size_t>(lrintf(crop_end * sample_rate), pcm.size());
+ }
+ return std::vector<float>(pcm.begin() + start_sample, pcm.begin() + end_sample);
+}
+