mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LibAudio: Allow resampling from any array-like type
This commit is contained in:
parent
5d01db3493
commit
63d9ec8e94
1 changed files with 16 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Concepts.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
|
||||||
|
@ -50,6 +51,21 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<ArrayLike<SampleType> Samples>
|
||||||
|
Vector<SampleType> resample(Samples&& to_resample)
|
||||||
|
{
|
||||||
|
Vector<SampleType> resampled;
|
||||||
|
resampled.ensure_capacity(to_resample.size() * ceil_div(m_source, m_target));
|
||||||
|
for (auto sample : to_resample) {
|
||||||
|
process_sample(sample, sample);
|
||||||
|
|
||||||
|
while (read_sample(sample, sample))
|
||||||
|
resampled.unchecked_append(sample);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resampled;
|
||||||
|
}
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
m_current_ratio = 0;
|
m_current_ratio = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue