Zao SDK for Jetson / libzao-endpoint API リファレンス 1.2.0.0 (2023-10-30)
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
14class PcmFormat {
15 public:
20 PcmFormat() noexcept {}
21
28 PcmFormat(int sampling_rate, unsigned channel_mask) noexcept {
29 SetSamplingRate(sampling_rate);
30 SetChannelMask(channel_mask);
31 }
32
36 int GetSamplingRate() const noexcept { return sampling_rate_; }
37
43 void SetSamplingRate(int new_value) noexcept { sampling_rate_ = new_value; }
44
48 enum ChannelBits : unsigned {
49 kLeftChannel = (1u << 0),
50 kRightChannel = (1u << 1),
51 kStereo = kLeftChannel | kRightChannel,
52 };
53
59 unsigned GetChannelMask() const noexcept { return channel_mask_; }
60
66 void SetChannelMask(unsigned new_value) noexcept {
67 channel_mask_ = new_value;
68 }
69
74 int GetNumOfChannels() const noexcept {
75 auto mask = channel_mask_;
76 int num_of_channels = 0;
77 while (mask) {
78 if (mask & 1) {
79 ++num_of_channels;
80 }
81 mask >>= 1;
82 }
83 return num_of_channels;
84 }
85
93 bool operator==(const PcmFormat& other) const noexcept {
94 return sampling_rate_ == other.sampling_rate_ &&
95 channel_mask_ == other.channel_mask_;
96 }
97
105 bool operator!=(const PcmFormat& other) const noexcept {
106 return !(*this == other);
107 }
108
109 private:
113 int sampling_rate_ = 0;
114
118 unsigned channel_mask_ = 0u;
119};
120
121} // namespace audio
122} // namespace endpoint
123} // namespace zao
124
125#endif // ZAO_ENDPOINT_AUDIO_PCM_FORMAT_HPP_
PCM音声のフォーマット
Definition PcmFormat.hpp:14
PcmFormat(int sampling_rate, unsigned channel_mask) noexcept
PcmFormatオブジェクトを初期値付きで構築する。
Definition PcmFormat.hpp:28
void SetSamplingRate(int new_value) noexcept
サンプリングレート(Hz単位)を設定する。
Definition PcmFormat.hpp:43
int GetSamplingRate() const noexcept
サンプリングレート(Hz単位)を取得する。
Definition PcmFormat.hpp:36
ChannelBits
チャンネルマスクの値定義
Definition PcmFormat.hpp:48
unsigned GetChannelMask() const noexcept
チャンネルマスクを取得する。
Definition PcmFormat.hpp:59
int GetNumOfChannels() const noexcept
チャンネル数を取得する。
Definition PcmFormat.hpp:74
bool operator!=(const PcmFormat &other) const noexcept
PcmFormat同士を非等値比較する
Definition PcmFormat.hpp:105
bool operator==(const PcmFormat &other) const noexcept
PcmFormat同士を等値比較する
Definition PcmFormat.hpp:93
void SetChannelMask(unsigned new_value) noexcept
チャンネルマスクを設定する。
Definition PcmFormat.hpp:66
PcmFormat() noexcept
PcmFormatオブジェクトをデフォルト構築する。
Definition PcmFormat.hpp:20
Zao製品共通の名前空間
Definition FactoryInterface.hpp:11