swift
samples.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_SAMPLES_H
7 #define SWIFT_SOUND_SAMPLEPROVIDER_SAMPLES_H
8 
9 #include <QObject>
10 
12 #include "misc/settingscache.h"
14 #include "sound/swiftsoundexport.h"
15 
16 namespace swift::sound::sample_provider
17 {
19  class SWIFT_SOUND_EXPORT Samples : public QObject
20  {
21  public:
23  static const Samples &instance();
24 
26  Samples(const Samples &) = delete;
27 
30  const CResourceSound &crackle() const { return m_crackle; }
31  const CResourceSound &click() const { return m_click; }
32  const CResourceSound &whiteNoise() const { return m_whiteNoise; }
33  const CResourceSound &hfWhiteNoise() const { return m_hfWhiteNoise; }
35 
37  bool playClick() const { return m_audioSettings.get().pttClickUp(); }
38 
41  static const QString &fnCrackle()
42  {
43  static const QString f = "afv_crackle_f32.wav";
44  return f;
45  }
46  static const QString &fnClick()
47  {
48  static const QString f = "afv_click_f32.wav";
49  return f;
50  }
51  static const QString &fnWhiteNoise()
52  {
53  static const QString f = "afv_whitenoise_f32.wav";
54  return f;
55  }
56  static const QString &fnHfWhiteNoise()
57  {
58  static const QString f = "afv_hf_whiteNoise_f32.wav";
59  return f;
60  }
62 
63  private:
65  Samples();
66 
67  CResourceSound m_crackle;
68  CResourceSound m_click;
69  CResourceSound m_whiteNoise;
70  CResourceSound m_hfWhiteNoise;
71 
72  swift::misc::CSetting<swift::misc::audio::TSettings> m_audioSettings { this, &Samples::onSettingsChanged };
73 
75  void initSounds();
76 
78  void onSettingsChanged();
79  };
80 
81 } // namespace swift::sound::sample_provider
82 
83 #endif // SWIFT_SOUND_SAMPLEPROVIDER_SAMPLES_H
Sound samples from resources (wav files)
Definition: samples.h:20
bool playClick() const
Play the click sound.
Definition: samples.h:37
const CResourceSound & crackle() const
Various samples (sounds)
Definition: samples.h:30
const CResourceSound & hfWhiteNoise() const
Various samples (sounds)
Definition: samples.h:33
static const QString & fnHfWhiteNoise()
File names.
Definition: samples.h:56
Samples(const Samples &)=delete
Avoid to copy.
const CResourceSound & click() const
Various samples (sounds)
Definition: samples.h:31
const CResourceSound & whiteNoise() const
Various samples (sounds)
Definition: samples.h:32
static const QString & fnClick()
File names.
Definition: samples.h:46
static const QString & fnWhiteNoise()
File names.
Definition: samples.h:51
static const QString & fnCrackle()
File names.
Definition: samples.h:41
#define SWIFT_SOUND_EXPORT
Export a class or function from the library.