1.10
sound.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_SOUND_H
7#define EGT_SOUND_H
8
14#include <egt/detail/meta.h>
15#include <memory>
16#include <string>
17
18namespace egt
19{
20inline namespace v1
21{
22
23namespace detail
24{
25struct soundimpl;
26}
27
28namespace experimental
29{
30
52class EGT_API Sound
53{
54public:
55
60 explicit Sound(const std::string& uri,
61 const std::string& device = "default");
62
69 explicit Sound(const std::string& uri, unsigned int rate, int channels,
70 const std::string& device = "default");
71
72 Sound(const Sound&) = delete;
73 Sound& operator=(const Sound&) = delete;
74 Sound(Sound&&) noexcept;
75 Sound& operator=(Sound&&) noexcept;
76
81 void media(const std::string& uri);
82
91 void play(bool repeat = false);
92
93 void stop();
94
95 virtual ~Sound() noexcept;
96
103 static std::vector<std::string> enumerate_pcm_devices();
104
105protected:
107 void open_alsa_device(const std::string& device);
109 void init_alsa_params(unsigned int rate, int channels);
111 void open_file();
112
114 std::unique_ptr<detail::soundimpl> m_impl;
115
117 std::string m_uri;
118};
119
120}
121}
122}
123
124#endif
Simple class to manage playing raw or WAV PCM sound files.
Definition sound.h:53
Sound(const std::string &uri, const std::string &device="default")
Sound & operator=(const Sound &)=delete
Sound(const std::string &uri, unsigned int rate, int channels, const std::string &device="default")
Sound(const Sound &)=delete
Sound(Sound &&) noexcept
EGT framework namespace.
Definition animation.h:24