1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PCM_2_WAV_H 17 #define PCM_2_WAV_H 18 19 #include <cstdint> 20 21 struct WAV_HEADER { 22 /* RIFF Chunk Descriptor */ 23 uint8_t RIFF[4] = {'R', 'I', 'F', 'F'}; // RIFF Header Magic header 24 uint32_t ChunkSize = 0; // RIFF Chunk Size 25 uint8_t WAVE[4] = {'W', 'A', 'V', 'E'}; // WAVE Header 26 /* "fmt" sub-chunk */ 27 uint8_t fmt[4] = {'f', 'm', 't', ' '}; // FMT header 28 uint32_t Subchunk1Size = 16; // Size of the fmt chunk 29 uint16_t AudioFormat = 1; // Audio format 1=PCM 30 uint16_t NumOfChan = 2; // Number of channels 1=Mono 2=Stereo 31 uint32_t SamplesPerSec = 44100; // Sampling Frequency in Hz 32 uint32_t bytesPerSec = 176400; // bytes per second 33 uint16_t blockAlign = 2; // 2=16-bit mono, 4=16-bit stereo 34 uint16_t bitsPerSample = 16; // Number of bits per sample 35 /* "data" sub-chunk */ 36 uint8_t Subchunk2ID[4] = {'d', 'a', 't', 'a'}; // "data" string 37 uint32_t Subchunk2Size = 0; // Sampled data length 38 }; 39 40 using wav_hdr = struct WAV_HEADER; 41 #endif // PCM_2_WAV_H