Zao SDK for Jetson / libzao-endpoint API リファレンス 1.6.0.0 (2024-12-24)
Loading...
Searching...
No Matches
PcmFormat.hpp
1#ifndef ZAO_ENDPOINT_AUDIO_PCM_FORMAT_HPP_
2#define ZAO_ENDPOINT_AUDIO_PCM_FORMAT_HPP_
3
4#include <memory>
5#include <string>
6
7namespace zao {
8namespace endpoint {
9namespace audio {
10
15class PcmFormat {
16 public:
23 PcmFormat() noexcept {}
24
34 PcmFormat(int sampling_rate, unsigned channel_mask) noexcept {
35 SetSamplingRate(sampling_rate);
36 SetChannelMask(channel_mask);
37 }
38
43 int GetSamplingRate() const noexcept { return sampling_rate_; }
44
52 void SetSamplingRate(int new_value) noexcept { sampling_rate_ = new_value; }
53
58 enum ChannelBits : unsigned {
59 kLeftChannel = (1u << 0),
60 kRightChannel = (1u << 1),
61 kStereo = kLeftChannel | kRightChannel,
62 };
63
71 unsigned GetChannelMask() const noexcept { return channel_mask_; }
72
80 void SetChannelMask(unsigned new_value) noexcept {
81 channel_mask_ = new_value;
82 }
83
90 int GetNumOfChannels() const noexcept {
91 auto mask = channel_mask_;
92 int num_of_channels = 0;
93 while (mask) {
94 if (mask & 1) {
95 ++num_of_channels;
96 }
97 mask >>= 1;
98 }
99 return num_of_channels;
100 }
101
113 bool operator==(const PcmFormat& other) const noexcept {
114 return sampling_rate_ == other.sampling_rate_ &&
115 channel_mask_ == other.channel_mask_;
116 }
117
129 bool operator!=(const PcmFormat& other) const noexcept {
130 return !(*this == other);
131 }
132
133 private:
138 int sampling_rate_ = 0;
139
144 unsigned channel_mask_ = 0u;
145};
146
147} // namespace audio
148} // namespace endpoint
149} // namespace zao
150
151#endif // ZAO_ENDPOINT_AUDIO_PCM_FORMAT_HPP_
PCM音声のフォーマット
Definition PcmFormat.hpp:15
PcmFormat(int sampling_rate, unsigned channel_mask) noexcept
PcmFormat オブジェクトを初期値付きで構築する。
Definition PcmFormat.hpp:34
void SetSamplingRate(int new_value) noexcept
サンプリングレート(Hz単位)を設定する。
Definition PcmFormat.hpp:52
int GetSamplingRate() const noexcept
サンプリングレート(Hz単位)を取得する。
Definition PcmFormat.hpp:43
ChannelBits
チャンネルマスクの値定義
Definition PcmFormat.hpp:58
unsigned GetChannelMask() const noexcept
チャンネルマスクを取得する。
Definition PcmFormat.hpp:71
int GetNumOfChannels() const noexcept
チャンネル数を取得する。
Definition PcmFormat.hpp:90
bool operator!=(const PcmFormat &other) const noexcept
PcmFormat同士を非等値比較する
Definition PcmFormat.hpp:129
bool operator==(const PcmFormat &other) const noexcept
PcmFormat同士を等値比較する
Definition PcmFormat.hpp:113
void SetChannelMask(unsigned new_value) noexcept
チャンネルマスクを設定する。
Definition PcmFormat.hpp:80
PcmFormat() noexcept
PcmFormat オブジェクトをデフォルト構築する。
Definition PcmFormat.hpp:23
Zao製品共通の名前空間
Definition FactoryInterface.hpp:11