Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
audio_input_selection.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <string_view>
7
8#include "utils/qt.h"
9#include "utils/utf8_string.h"
10
11#include <QObject>
12#include <QtQmlIntegration/qqmlintegration.h>
13
14#include <nlohmann/json_fwd.hpp>
15
16using namespace std::string_view_literals;
17
18namespace zrythm::dsp
19{
20
27class AudioInputSelection : public QObject
28{
29 Q_OBJECT
30 Q_PROPERTY (
31 QString deviceName READ deviceName WRITE setDeviceName NOTIFY
32 deviceNameChanged)
33 Q_PROPERTY (
34 int firstChannel READ firstChannel WRITE setFirstChannel NOTIFY
35 firstChannelChanged)
36 Q_PROPERTY (bool stereo READ stereo WRITE setStereo NOTIFY stereoChanged)
37 QML_ELEMENT
38 QML_UNCREATABLE ("Created by ProjectUiState")
39
40public:
41 explicit AudioInputSelection (QObject * parent = nullptr) : QObject (parent)
42 {
43 }
44 ~AudioInputSelection () override = default;
45 Q_DISABLE_COPY_MOVE (AudioInputSelection)
46
47 QString deviceName () const;
48 void setDeviceName (const QString &name);
49 Q_SIGNAL void deviceNameChanged ();
50
51 int firstChannel () const { return first_channel_; }
52 void setFirstChannel (int channel);
53 Q_SIGNAL void firstChannelChanged ();
54
55 bool stereo () const { return stereo_; }
56 void setStereo (bool s);
57 Q_SIGNAL void stereoChanged ();
58
59 friend bool
60 operator== (const AudioInputSelection &a, const AudioInputSelection &b);
61
62 static constexpr auto kDeviceNameKey = "deviceName"sv;
63 static constexpr auto kFirstChannelKey = "firstChannel"sv;
64 static constexpr auto kStereoKey = "stereo"sv;
65
66private:
67 friend void to_json (nlohmann::json &j, const AudioInputSelection &sel);
68 friend void from_json (const nlohmann::json &j, AudioInputSelection &sel);
69
70 utils::Utf8String device_name_;
71 uint8_t first_channel_ = 0;
72 bool stereo_ = true;
73};
74
75} // namespace zrythm::dsp
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:37