swift
resourcesoundsampleprovider.h
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 
4 #ifndef SWIFT_SOUND_SAMPLEPROVIDER_RESOURCESOUNDSAMPLEPROVIDER_H
5 #define SWIFT_SOUND_SAMPLEPROVIDER_RESOURCESOUNDSAMPLEPROVIDER_H
6 
10 
11 namespace swift::sound::sample_provider
12 {
15  {
16  Q_OBJECT
17 
18  public:
20  CResourceSoundSampleProvider(const CResourceSound &resourceSound, QObject *parent = nullptr);
21 
23  virtual int readSamples(QVector<float> &samples, qint64 count) override;
24 
26  virtual bool isFinished() const override { return m_isFinished; }
27 
30  bool looping() const { return m_looping; }
31  void setLooping(bool looping) { m_looping = looping; }
33 
36  double gain() const { return m_gain; }
37  void setGain(double gain) { m_gain = gain; }
39 
40  private:
41  double m_gain = 1.0;
42  bool m_looping = false;
43 
44  CResourceSound m_resourceSound;
45  qint64 m_position = 0;
46  const int m_tempBufferSize =
47  24000; // 24000 = 500ms (avoid buffer overflow), m_tempBufferSize = 9600; //9600 = 200ms
48  QVector<float> m_tempBuffer;
49  bool m_isFinished = false;
50  };
51 } // namespace swift::sound::sample_provider
52 
53 #endif // SWIFT_SOUND_SAMPLEPROVIDER_RESOURCESOUNDSAMPLEPROVIDER_H
virtual bool isFinished() const
copydoc ISampleProvider::isFinished
#define SWIFT_SOUND_EXPORT
Export a class or function from the library.