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 struct WAV_HEADER { 19 /* RIFF Chunk Descriptor */ 20 uint8_t RIFF[4] = {'R', 'I', 'F', 'F'}; // RIFF Header Magic header 21 uint32_t ChunkSize = 0; // RIFF Chunk Size 22 uint8_t WAVE[4] = {'W', 'A', 'V', 'E'}; // WAVE Header 23 /* "fmt" sub-chunk */ 24 uint8_t fmt[4] = {'f', 'm', 't', ' '}; // FMT header 25 uint32_t Subchunk1Size = 16; // Size of the fmt chunk 26 uint16_t AudioFormat = 1; // Audio format 1=PCM 27 uint16_t NumOfChan = 2; // Number of channels 1=Mono 2=Sterio 28 uint32_t SamplesPerSec = 44100; // Sampling Frequency in Hz 29 uint32_t bytesPerSec = 176400; // bytes per second 30 uint16_t blockAlign = 2; // 2=16-bit mono, 4=16-bit stereo 31 uint16_t bitsPerSample = 16; // Number of bits per sample 32 /* "data" sub-chunk */ 33 uint8_t Subchunk2ID[4] = {'d', 'a', 't', 'a'}; // "data" string 34 uint32_t Subchunk2Size = 0; // Sampled data length 35 }; 36 37 using wav_hdr = struct WAV_HEADER; 38 #endif // PCM_2_WAV_H