swift
resourcesound.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_RESOURCESOUND_H
7 #define SWIFT_SOUND_SAMPLEPROVIDER_RESOURCESOUND_H
8 
9 #include <atomic>
10 
11 #include <QExplicitlySharedDataPointer>
12 #include <QString>
13 #include <QVector>
14 
15 #include "misc/worker.h"
16 #include "sound/swiftsoundexport.h"
17 #include "sound/wav/wavfile.h"
18 
19 namespace swift::sound::sample_provider
20 {
22  struct CResourceSoundData : public QSharedData
23  {
24  QString fileName;
25  bool isLoaded = false;
26  QVector<float> samples;
27  };
28 
31  {
32  public:
35 
37  CResourceSound(const QString &audioFileName);
38 
40  bool load();
41 
43  bool isLoaded() { return m_data->isLoaded; }
44 
46  const QVector<float> &audioData() const { return m_data->samples; }
47 
49  const QString &getFileName() const;
50 
52  bool isSameFileName(const QString &fn) const;
53 
54  private:
55  QExplicitlySharedDataPointer<CResourceSoundData> m_data;
56  };
57 } // namespace swift::sound::sample_provider
58 
59 #endif // SWIFT_SOUND_SAMPLEPROVIDER_RESOURCESOUND_H
bool isLoaded()
Is resource already loaded?
Definition: resourcesound.h:43
const QString & getFileName() const
Corresponding file.
const QVector< float > & audioData() const
Audio data.
Definition: resourcesound.h:46
bool load()
Load the attached resource file.
bool isSameFileName(const QString &fn) const
Is same file?