23 void put(AudioSampleImplPtr&& impl) {
41 AudioSampleImplPtr impl =
pool.back();
77 return mImpl->pcm().size();
95 if (
mImpl ==
nullptr || other.
mImpl ==
nullptr) {
98 if (
mImpl->pcm().size() != other.
mImpl->pcm().size()) {
101 for (fl::size i = 0; i <
mImpl->pcm().
size(); ++i) {
102 if (
mImpl->pcm()[i] != other.
mImpl->pcm()[i]) {
110 return !(*
this == other);
114 static fl::i16 empty_data[1] = {0};
123 return mImpl->timestamp();
133 const int N =
size();
134 for (
int i = 0; i < N; ++i) {
135 fl::i32 x32 = fl::i32(
pcm()[i]);
138 float rms = sqrtf(
float(sum_sq) / N);
150 for (fl::size i = 0; i < count; ++i) {
151 double s = samples[i] / 32768.0;
154 double p = sum_sq / count;
155 double dbfs = 10.0 * log10(p + 1e-12);
182 get_flex_fft().
run(sample, out,
args);
187 mImpl = AudioSamplePool::instance().getOrCreate();
const VectorPCM & pcm() const
fl::vector< fl::i16 > VectorPCM
bool operator!=(const AudioSample &other) const
bool operator==(const AudioSample &other) const
const fl::i16 & operator[](fl::size i) const
void fft(FFTBins *out) const
const fl::i16 & at(fl::size i) const
fl::u32 timestamp() const
const_iterator begin() const
const_iterator end() const
AudioSample & operator=(const AudioSample &other)
static const VectorPCM & empty()
void run(const span< const i16 > &sample, FFTBins *out, const FFT_Args &args=FFT_Args())
SoundLevelMeter(double spl_floor=33.0, double smoothing_alpha=0.0)
double dbfs_floor_global_
void processBlock(const fl::i16 *samples, fl::size count)
Process a block of int16 PCM samples.
constexpr remove_reference< T >::type && move(T &&t) noexcept
ThreadLocalFake< T > ThreadLocal
shared_ptr< T > make_shared(Args &&... args)
HeapVector< T, Allocator > vector
static int DefaultSampleRate()
static float DefaultMinFrequency()
static float DefaultMaxFrequency()
static constexpr fl::size MAX_POOL_SIZE
AudioSampleImplPtr getOrCreate()
void put(AudioSampleImplPtr &&impl)
fl::vector< AudioSampleImplPtr > pool
static AudioSamplePool & instance()