~aleteoryx/muditaos

ref: 0a0366bb7474f15400948d9209cdc19274ab0e5d muditaos/module-audio/Audio/decoder/decoderWAV.hpp -rw-r--r-- 1.2 KiB
0a0366bb — Piotr Tanski [EGD-4267] Don't clean application windows if the application switch is not yet confirmed. (#1040) 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "decoder.hpp"

namespace audio
{

    class decoderWAV : public decoder
    {

      public:
        decoderWAV(const char *fileName);

        ~decoderWAV()
        {}

        uint32_t decode(uint32_t samplesToRead, int16_t *pcmData) override;

        void setPosition(float pos) override;

      private:
        using WAVE_FormatTypeDef = struct
        {
            uint32_t ChunkID;       /* 0 */
            uint32_t FileSize;      /* 4 */
            uint32_t FileFormat;    /* 8 */
            uint32_t SubChunk1ID;   /* 12 */
            uint32_t SubChunk1Size; /* 16*/
            uint16_t AudioFormat;   /* 20 */
            uint16_t NbrChannels;   /* 22 */
            uint32_t SampleRate;    /* 24 */

            uint32_t ByteRate;      /* 28 */
            uint16_t BlockAlign;    /* 32 */
            uint16_t BitPerSample;  /* 34 */
            uint32_t SubChunk2ID;   /* 36 */
            uint32_t SubChunk2Size; /* 40 */
        };

        std::vector<int32_t> pcmsamplesbuffer;
        WAVE_FormatTypeDef waveHeader;
        uint32_t bitsPerSample;
    };

} // namespace audio