mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 17:55:45 +08:00
42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
|
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
|
|
|
//! \file
|
|
|
|
#ifndef PINKNOISEGENERATOR_H
|
|
#define PINKNOISEGENERATOR_H
|
|
|
|
#include "sound/swiftsoundexport.h"
|
|
#include "sound/sampleprovider/sampleprovider.h"
|
|
|
|
#include <QRandomGenerator>
|
|
#include <QVector>
|
|
|
|
#include <array>
|
|
|
|
namespace swift::sound::sample_provider
|
|
{
|
|
//! Pink noise generator
|
|
class SWIFT_SOUND_EXPORT CPinkNoiseGenerator : public ISampleProvider
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
//! Noise generator
|
|
CPinkNoiseGenerator(QObject *parent = nullptr) : ISampleProvider(parent) {}
|
|
|
|
//! Read samples
|
|
virtual int readSamples(QVector<float> &samples, qint64 count) override;
|
|
|
|
//! Gain
|
|
void setGain(double gain) { m_gain = gain; }
|
|
|
|
private:
|
|
QRandomGenerator m_random;
|
|
std::array<double, 7> m_pinkNoiseBuffer = { { 0 } };
|
|
double m_gain = 0.0;
|
|
};
|
|
}
|
|
|
|
#endif // guard
|