swift
sinusgenerator.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 SWIFT_SOUND_SAMPLEPROVIDER_SINUSGENERATOR_H
7 #define SWIFT_SOUND_SAMPLEPROVIDER_SINUSGENERATOR_H
8 
9 #include <QtMath>
10 
12 #include "sound/swiftsoundexport.h"
13 
14 namespace swift::sound::sample_provider
15 {
18  {
19  Q_OBJECT
20 
21  public:
23  CSinusGenerator(double frequencyHz, QObject *parent = nullptr);
24 
26  virtual int readSamples(QVector<float> &samples, qint64 count) override;
27 
29  void setGain(double gain) { m_gain = gain; }
30 
32  void setFrequency(double frequencyHz);
33 
34  private:
35  double m_gain = 0.0;
36  double m_frequencyHz = 0.0;
37  double m_sampleRate = 48000;
38  int m_nSample = 0;
39  static constexpr double s_twoPi = 2 * M_PI;
40  };
41 } // namespace swift::sound::sample_provider
42 
43 #endif // SWIFT_SOUND_SAMPLEPROVIDER_SINUSGENERATOR_H
void setGain(double gain)
Set the gain.
#define SWIFT_SOUND_EXPORT
Export a class or function from the library.