1.11
sound_effect.h
1/*
2 * Copyright (C) 2025 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_SOUND_EFFECT_H
7#define EGT_SOUND_EFFECT_H
8
14#include <string>
15
16#include <egt/detail/meta.h>
17
18namespace egt
19{
20inline namespace v1
21{
22
23namespace detail
24{
25class SoundEffectImpl;
26}
27
41class EGT_API SoundEffect final
42{
43public:
44
51 {
52 public:
53
58 SoundDevice(int card_index = 0, int device_index = 0) noexcept
59 : m_card_index(card_index), m_device_index(device_index)
60 {
61 }
62
68 void card_index(int card_index)
69 {
70 m_card_index = card_index;
71 }
72
76 EGT_NODISCARD int card_index() const
77 {
78 return m_card_index;
79 }
80
86 void card_name(const std::string& card_name)
87 {
88 m_card_name = card_name;
89 }
90
94 EGT_NODISCARD std::string card_name() const
95 {
96 return m_card_name;
97 }
98
104 void device_index(int device_index)
105 {
106 m_device_index = device_index;
107 }
108
112 EGT_NODISCARD int device_index() const
113 {
114 return m_device_index;
115 }
116
122 void device_name(std::string device_name)
123 {
124 m_device_name = device_name;
125 }
126
130 EGT_NODISCARD std::string device_name() const
131 {
132 return m_device_name;
133 }
134
135 private:
136
137 int m_card_index{0};
138 std::string m_card_name{};
139 int m_device_index{0};
140 std::string m_device_name{};
141 };
142
150 explicit SoundEffect(const std::string& uri, const SoundDevice& sound_device = {});
151
157 SoundEffect() noexcept;
158
159 SoundEffect(const SoundEffect&) = delete;
160
161 SoundEffect& operator=(const SoundEffect&) = delete;
162
163 ~SoundEffect() noexcept;
164
173 bool device(const SoundDevice& sound_device) noexcept;
174
178 EGT_NODISCARD const SoundDevice& device() const;
179
187 bool media(const std::string& uri) noexcept;
188
192 std::string media() const;
193
197 void repeat(bool value);
198
202 EGT_NODISCARD bool repeat() const;
203
207 void play();
208
212 void stop();
213
218 static std::vector<SoundDevice> sound_device_list();
219
220private:
221
222 std::unique_ptr<detail::SoundEffectImpl> m_impl;
223};
224
225}
226}
227
228#endif
The SoundDevice object is used to describe an ALSA PCM device.
Definition sound_effect.h:51
void device_index(int device_index)
Set the sound device index.
Definition sound_effect.h:104
SoundDevice(int card_index=0, int device_index=0) noexcept
Definition sound_effect.h:58
void card_index(int card_index)
Set the sound card index.
Definition sound_effect.h:68
EGT_NODISCARD std::string device_name() const
Get the sound device name.
Definition sound_effect.h:130
EGT_NODISCARD std::string card_name() const
Get the sound card name.
Definition sound_effect.h:94
EGT_NODISCARD int device_index() const
Get the sound device index.
Definition sound_effect.h:112
void device_name(std::string device_name)
Set the sound device name.
Definition sound_effect.h:122
void card_name(const std::string &card_name)
Set the sound card name.
Definition sound_effect.h:86
EGT_NODISCARD int card_index() const
Get the sound card index.
Definition sound_effect.h:76
Notification Sound Effect.
Definition sound_effect.h:42
SoundEffect() noexcept
SoundEffect default constructor.
SoundEffect(const std::string &uri, const SoundDevice &sound_device={})
SoundEffect constructor.
EGT framework namespace.
Definition animation.h:24