Zao SDK for Jetson / libzep API Reference
Loading...
Searching...
No Matches
PcmFormat.hpp
1/*
2 * Copyright (c) 2022-2023, Soliton Systems K.K. All rights reserved.
3 * Use in source and binary forms, with or without modification,
4 * is permitted provided that the following a condition is met:
5 *
6 * Use is permitted only in accordance with the terms and
7 * conditions set forth in the Software License Agreement available
8 * at https://zao-sdk.org/license-agreement/.
9 */
10#ifndef ZEP_AUDIO_PCM_FORMAT_HPP_
11#define ZEP_AUDIO_PCM_FORMAT_HPP_
12
13#include <memory>
14#include <string>
15
16namespace zep {
17namespace audio {
18
22class PcmFormat {
23 public:
28 PcmFormat() noexcept {}
29
36 PcmFormat(int sampling_rate, unsigned channel_mask) noexcept {
37 SetSamplingRate(sampling_rate);
38 SetChannelMask(channel_mask);
39 }
40
44 int GetSamplingRate() const noexcept { return sampling_rate_; }
45
51 void SetSamplingRate(int new_value) noexcept { sampling_rate_ = new_value; }
52
56 enum ChannelBits : unsigned {
57 kLeftChannel = (1u << 0),
58 kRightChannel = (1u << 1),
59 kStereo = kLeftChannel | kRightChannel,
60 };
61
67 unsigned GetChannelMask() const noexcept { return channel_mask_; }
68
74 void SetChannelMask(unsigned new_value) noexcept {
75 channel_mask_ = new_value;
76 }
77
82 int GetNumOfChannels() const noexcept {
83 auto mask = channel_mask_;
84 int num_of_channels = 0;
85 while (mask) {
86 if (mask & 1) {
87 ++num_of_channels;
88 }
89 mask >>= 1;
90 }
91 return num_of_channels;
92 }
93
101 bool operator==(const PcmFormat& other) const noexcept {
102 return sampling_rate_ == other.sampling_rate_ &&
103 channel_mask_ == other.channel_mask_;
104 }
105
113 bool operator!=(const PcmFormat& other) const noexcept {
114 return !(*this == other);
115 }
116
117 private:
121 int sampling_rate_ = 0;
122
126 unsigned channel_mask_ = 0u;
127};
128
129} // namespace audio
130} // namespace zep
131
132#endif // ZEP_AUDIO_PCM_FORMAT_HPP_
PCM audio format.
Definition PcmFormat.hpp:22
bool operator==(const PcmFormat &other) const noexcept
PcmFormat同士を等値比較する
Definition PcmFormat.hpp:101
void SetChannelMask(unsigned new_value) noexcept
チャンネルマスクを設定する。
Definition PcmFormat.hpp:74
PcmFormat() noexcept
PcmFormatオブジェクトをデフォルト構築する。
Definition PcmFormat.hpp:28
int GetNumOfChannels() const noexcept
チャンネル数を取得する。
Definition PcmFormat.hpp:82
PcmFormat(int sampling_rate, unsigned channel_mask) noexcept
PcmFormatオブジェクトを初期値付きで構築する。
Definition PcmFormat.hpp:36
ChannelBits
チャンネルマスクの値定義
Definition PcmFormat.hpp:56
void SetSamplingRate(int new_value) noexcept
サンプリングレート(Hz単位)を設定する。
Definition PcmFormat.hpp:51
bool operator!=(const PcmFormat &other) const noexcept
PcmFormat同士を非等値比較する
Definition PcmFormat.hpp:113
int GetSamplingRate() const noexcept
サンプリングレート(Hz単位)を取得する。
Definition PcmFormat.hpp:44
unsigned GetChannelMask() const noexcept
チャンネルマスクを取得する。
Definition PcmFormat.hpp:67
Namespace for ZEP SDK.
Definition FactoryInterface.hpp:19