swift
pinknoisegenerator.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef PINKNOISEGENERATOR_H
7 #define PINKNOISEGENERATOR_H
8 
9 #include <array>
10 
11 #include <QRandomGenerator>
12 #include <QVector>
13 
15 #include "sound/swiftsoundexport.h"
16 
17 namespace swift::sound::sample_provider
18 {
21  {
22  Q_OBJECT
23 
24  public:
26  CPinkNoiseGenerator(QObject *parent = nullptr) : ISampleProvider(parent) {}
27 
29  virtual int readSamples(QVector<float> &samples, qint64 count) override;
30 
32  void setGain(double gain) { m_gain = gain; }
33 
34  private:
35  QRandomGenerator m_random;
36  std::array<double, 7> m_pinkNoiseBuffer = { { 0 } };
37  double m_gain = 0.0;
38  };
39 } // namespace swift::sound::sample_provider
40 
41 #endif // PINKNOISEGENERATOR_H
CPinkNoiseGenerator(QObject *parent=nullptr)
Noise generator.
#define SWIFT_SOUND_EXPORT
Export a class or function from the library.