AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AudioFormat.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
19 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_AUDIOFORMAT_H_
20 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_AUDIOFORMAT_H_
21 
22 #include <ostream>
23 
24 namespace alexaClientSDK {
25 namespace avsCommon {
26 namespace utils {
27 
31 struct AudioFormat {
35  enum class Encoding {
37  LPCM,
38 
40  OPUS
41  };
42 
46  enum class Layout {
48  NON_INTERLEAVED,
49 
51  INTERLEAVED
52  };
53 
57  enum class Endianness {
59  LITTLE,
60 
62  BIG
63  };
64 
67 
70 
72  unsigned int sampleRateHz;
73 
75  unsigned int sampleSizeInBits;
76 
78  unsigned int numChannels;
79 
81  bool dataSigned;
82 
85 };
86 
94 inline std::ostream& operator<<(std::ostream& stream, const AudioFormat::Encoding& encoding) {
95  switch (encoding) {
97  stream << "LPCM";
98  break;
100  stream << "OPUS";
101  break;
102  }
103  return stream;
104 }
105 
113 inline std::ostream& operator<<(std::ostream& stream, const AudioFormat::Endianness& endianness) {
114  switch (endianness) {
116  stream << "LITTLE";
117  break;
119  stream << "BIG";
120  break;
121  }
122  return stream;
123 }
124 
125 } // namespace utils
126 } // namespace avsCommon
127 } // namespace alexaClientSDK
128 
129 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_AUDIOFORMAT_H_
Represents LPCM (Linear pulse code modulation) encoding.
Endianness
Definition: AudioFormat.h:57
Layout layout
The layout of format for cases where numChannels > 1.
Definition: AudioFormat.h:84
unsigned int sampleRateHz
The number of samples recorded or played per second.
Definition: AudioFormat.h:72
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::ostream & operator<<(std::ostream &stream, const AudioFormat::Encoding &encoding)
Definition: AudioFormat.h:94
bool dataSigned
true if the data is signed false otherwise.
Definition: AudioFormat.h:81
Encoding encoding
The encoding of the data.
Definition: AudioFormat.h:66
Endianness endianness
The endianness of the data.
Definition: AudioFormat.h:69
unsigned int numChannels
The number of channels.
Definition: AudioFormat.h:78
unsigned int sampleSizeInBits
The bits per sample.
Definition: AudioFormat.h:75

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0