tilde~
Puredata Qt-based GUI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AudioSettings.h
Go to the documentation of this file.
1 // (c) 2017 Alex Nadzharov
2 // License: GPL3
3 
4 #ifndef CM_AudioSettings_H
5 #define CM_AudioSettings_H
6 
7 #include <QString>
8 #include <map>
9 #include <string.h>
10 
11 #include "PropertyList.h"
12 
13 #include <QDebug>
14 
15 #include "Preferences.h"
16 
17 //#include "pdServer.hpp"
18 
20 
21 #define AUDIOSETTINGS_QSTRING(x) tilde::AudioSettings::inst().getQString(x)
22 #define TILDE_AUDIOSETTINGS_INIT tilde::AudioSettings::inst().init()
23 #define AUDIOSETTINGS_LISTENER(x, y) connect(get(x), &Property::changed, this, y)
24 
25 namespace tilde {
26 
29 class AudioSettings : public PropertyList // TODO
30 {
31 public:
32  static AudioSettings& inst()
33  {
34  static AudioSettings instance;
35  return instance;
36  }
37 
38 private:
39  std::map<std::string, QString> _data;
40 
42  {
43  }
44 
45 public:
46  AudioSettings(AudioSettings const&) = delete;
47  void operator=(AudioSettings const&) = delete;
48 
49  //temporary
50  QString getQString(QString key)
51  {
52  if (get(key))
53  return get(key)->asQString();
54 
55  return "";
56  }
57 
58  void init()
59  {
60 
61  /*
62  // TODO
63  create("AudioDriver", "Basic", TILDE_APP_VERSION, QString(ServerInstance::getAudioAPIs().c_str()).split(","));
64 
65  get("AudioDriver")->setType(ptEnum);
66 
67  create("AudioInput", "Basic", TILDE_APP_VERSION, QString(ServerInstance::getAudioInDevices().c_str()).split(","));
68  get("AudioInput")->setType(ptEnum);
69  create("AudioOutput", "Basic", TILDE_APP_VERSION, QString(ServerInstance::getAudioOutDevices().c_str()).split(","));
70  get("AudioOutput")->setType(ptEnum);
71 
72  create("BufferSize", "Settings", TILDE_APP_VERSION, 256);
73  get("BufferSize")->setType(ptInt);
74  create("BlockSize", "Settings", TILDE_APP_VERSION, 64);
75  get("BlockSize")->setType(ptInt);
76  create("InputCount", "Settings", TILDE_APP_VERSION, 2);
77  get("InputCount")->setType(ptInt);
78  create("OutputCount", "Settings", TILDE_APP_VERSION, 2);
79  get("OutputCount")->setType(ptInt);
80 
81  AUDIOSETTINGS_LISTENER("AudioDriver", &AudioSettings::slotSetAudioDriver);
82  AUDIOSETTINGS_LISTENER("AudioInput", &AudioSettings::slotSetAudioInput);
83  AUDIOSETTINGS_LISTENER("AudioOutput", &AudioSettings::slotSetAudioOutput);
84  */
85  }
86 
87 private slots:
88  void slotSetAudioDriver() { qDebug() << "audio driver"; }
89  void slotSetAudioInput() {}
90  void slotSetAudioOutput() {}
91 };
92 }
93 
94 #endif // CM_AudioSettings_H
app AudioSettings singleton
Definition: AudioSettings.h:29
void init()
Definition: AudioSettings.h:58
QString getQString(QString key)
Definition: AudioSettings.h:50
static AudioSettings & inst()
Definition: AudioSettings.h:32
Property handling class for ui object - property list.
Definition: PropertyList.h:34
void operator=(AudioSettings const &)=delete
OOPD * instance
Definition: OOPD.cpp:20