score-plugin-audio/Audio/Settings/Model.hpp
1 #pragma once
2 #include <Audio/AudioInterface.hpp>
3 
4 #include <score/plugins/ProjectSettings/ProjectSettingsModel.hpp>
5 #include <score/plugins/settingsdelegate/SettingsDelegateModel.hpp>
6 
7 #include <score_plugin_audio_export.h>
8 
9 #include <verdigris>
10 
11 namespace Audio::Settings
12 {
13 
14 enum class ExternalTransport : int8_t
15 {
16  None = 0,
17  Client = 1,
18  Master = 2
19 };
20 
21 class SCORE_PLUGIN_AUDIO_EXPORT Model : public score::SettingsDelegateModel
22 {
23  W_OBJECT(Model)
24 
25  // JACK, MME, WASAPI, ALSA...
26  Audio::AudioFactory::ConcreteKey m_Driver{};
27 
28  // For APIs that support setting a name to the inputs / outputs (e.g. JACK)
29  QStringList m_InputNames;
30  QStringList m_OutputNames;
31 
32  // Which device to use for input / output
33  QString m_CardIn{};
34  QString m_CardOut{};
35  int m_BufferSize{};
36  int m_Rate{};
37 
38  // How many i/o to create if possible
39  int m_DefaultIn{};
40  int m_DefaultOut{};
41 
42  // When playing mono audio files, put them as stereo automatically
43  bool m_AutoStereo{true};
44 
45  // Auto connect ports to system i/o (mostly relevant for jack)
46  bool m_AutoConnect{true};
47 
48  // Use JACK Transport
49  ExternalTransport m_JackTransport{ExternalTransport::None};
50 
51 public:
52  Model(QSettings& set, const score::ApplicationContext& ctx);
53 
54  void changed() E_SIGNAL(SCORE_PLUGIN_AUDIO_EXPORT, changed)
55  SCORE_SETTINGS_PARAMETER_HPP(
56  SCORE_PLUGIN_AUDIO_EXPORT, Audio::AudioFactory::ConcreteKey, Driver)
57  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, QStringList, InputNames)
58  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, QStringList, OutputNames)
59  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, QString, CardIn)
60  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, QString, CardOut)
61  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, int, BufferSize)
62  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, int, Rate)
63  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, int, DefaultIn)
64  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, int, DefaultOut)
65  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, bool, AutoStereo)
66  SCORE_SETTINGS_PARAMETER_HPP(SCORE_PLUGIN_AUDIO_EXPORT, bool, AutoConnect)
67  SCORE_SETTINGS_PARAMETER_HPP(
68  SCORE_PLUGIN_AUDIO_EXPORT, Audio::Settings::ExternalTransport, JackTransport)
69 };
70 
71 SCORE_SETTINGS_PARAMETER(Model, Driver)
72 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, InputNames)
73 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, OutputNames)
74 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, CardIn)
75 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, CardOut)
76 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, BufferSize)
77 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, Rate)
78 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, DefaultIn)
79 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, DefaultOut)
80 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, AutoStereo)
81 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, AutoConnect)
82 SCORE_SETTINGS_DEFERRED_PARAMETER(Model, JackTransport)
83 }
84 
85 Q_DECLARE_METATYPE(Audio::Settings::ExternalTransport)
86 W_REGISTER_ARGTYPE(Audio::Settings::ExternalTransport)
87 #undef AUDIO_PARAMETER_HPP
Definition: score-plugin-audio/Audio/Settings/Model.hpp:22
Definition: SettingsDelegateModel.hpp:16
Used to access all the application-wide state and structures.
Definition: ApplicationContext.hpp:24