Update Slicer.hpp

This commit is contained in:
Ναρουσέ·μ·γιουμεμί·Χινακάννα 2023-04-08 00:06:56 +08:00 committed by GitHub
parent e7f05beb35
commit a89f2f12c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -9,6 +9,17 @@ struct SliceResult
cutResult(std::vector<unsigned long long>&& O, std::vector<bool>&& T) :SliceOffset(O), SliceTag(T) {}
};
double getAvg(const short* start, const short* end)
{
const auto size = end - start + 1;
auto avg = (double)(*start);
for (auto i = 1; i < size; i++)
{
avg = avg + (abs((double)start[i]) - avg) / (double)(i + 1ull);
}
return avg;
}
inline SliceResult SliceWav(Wav& input, double threshold, unsigned long minLen, unsigned short frame_len, unsigned short frame_shift)
{
const auto header = input.getHeader();
@ -68,3 +79,4 @@ inline SliceResult SliceWav(Wav& input, double threshold, unsigned long minLen,
}
return { std::move(output),std::move(tag) };
}