HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
audio_device.hpp
1// Copyright Take Vos 2019-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "audio_device_delegate.hpp"
8#include "audio_stream_config.hpp"
9#include "audio_channel.hpp"
10#include "audio_direction.hpp"
11#include "audio_device_state.hpp"
12#include "speaker_mapping.hpp"
13#include "../numeric/numeric.hpp"
14#include "../l10n/l10n.hpp"
15#include "../utility/utility.hpp"
16#include "../dispatch/dispatch.hpp"
17#include "../macros.hpp"
18#include <string>
19#include <memory>
20#include <ostream>
21
22hi_export_module(hikogui.audio.audio_device);
23
24hi_export namespace hi { inline namespace v1 {
25
34hi_export class audio_device {
35public:
36 audio_device() noexcept = default;
37 virtual ~audio_device() = default;
38
41 [[nodiscard]] std::string const& id() const noexcept
42 {
43 return _id;
44 }
45
50 [[nodiscard]] std::string name() const noexcept
51 {
52 hi_axiom(loop::main().on_thread());
53 return _name;
54 }
55
60 [[nodiscard]] virtual label label() const noexcept = 0;
61
66 virtual void update_state() noexcept = 0;
67
70 [[nodiscard]] virtual audio_device_state state() const noexcept = 0;
71
72 [[nodiscard]] virtual audio_direction direction() const noexcept = 0;
73
78 [[nodiscard]] virtual bool exclusive() const noexcept = 0;
79
94 virtual void set_exclusive(bool exclusive) noexcept = 0;
95
101 [[nodiscard]] virtual double sample_rate() const noexcept = 0;
102
106 virtual void set_sample_rate(double sample_rate) noexcept = 0;
107
112 [[nodiscard]] virtual hi::speaker_mapping input_speaker_mapping() const noexcept = 0;
113
118 virtual void set_input_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept = 0;
119
124 [[nodiscard]] virtual std::vector<hi::speaker_mapping> available_input_speaker_mappings() const noexcept = 0;
125
130 [[nodiscard]] virtual hi::speaker_mapping output_speaker_mapping() const noexcept = 0;
131
136 virtual void set_output_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept = 0;
137
142 [[nodiscard]] virtual std::vector<hi::speaker_mapping> available_output_speaker_mappings() const noexcept = 0;
143
158 // virtual void start_stream(std::string id, std::string name) = 0;
159
163 // virtual void stop_stream() noexcept = 0;
164
165protected:
166 std::string _id;
167 std::string _name;
168};
169
170}} // namespace hi::inline v1
STL namespace.
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
A set of audio channels which can be rendered and/or captures at the same time.
Definition audio_device.hpp:34
std::string name() const noexcept
Get a user friendly name of the audio device.
Definition audio_device.hpp:50
virtual std::vector< hi::speaker_mapping > available_input_speaker_mappings() const noexcept=0
Speaker mapping that are available in the current configuration.
virtual hi::speaker_mapping input_speaker_mapping() const noexcept=0
Get the currently configured input speaker mapping.
virtual double sample_rate() const noexcept=0
Get the currently configured sample rate.
virtual bool exclusive() const noexcept=0
Check if the device is in exclusive mode.
virtual void set_output_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept=0
Set the output speaker mapping.
virtual void update_state() noexcept=0
Update the internal state based on the audio device.
virtual audio_device_state state() const noexcept=0
Get the current state of the audio device.
virtual hi::speaker_mapping output_speaker_mapping() const noexcept=0
Get the currently configured output speaker mapping.
virtual void set_input_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept=0
Set the input speaker mapping.
virtual void set_sample_rate(double sample_rate) noexcept=0
Set the sample rate.
std::string const & id() const noexcept
The nonephemeral unique id that for an audio device on the system.
Definition audio_device.hpp:41
virtual label label() const noexcept=0
Get a user friendly label of the audio device.
virtual std::vector< hi::speaker_mapping > available_output_speaker_mappings() const noexcept=0
Speaker mapping that are available in the current configuration.
virtual void set_exclusive(bool exclusive) noexcept=0
Set the device in exclusive or shared mode.