Files
MuditaOS/module-audio/Audio/decoder/decoderWAV.hpp
Marcin Smoczyński 8b21df135c [EGD-5742] Add audio format checking
Check if decoder's file format is supported by the sink audio device
before playing the sound. Add list of supported formats to each of audio
devices.

Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
2021-04-12 10:00:00 +02:00

49 lines
1.3 KiB
C++

// 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"
#include <vector>
namespace audio
{
class decoderWAV : public Decoder
{
public:
decoderWAV(const char *fileName);
uint32_t decode(uint32_t samplesToRead, int16_t *pcmData) override;
void setPosition(float pos) override;
private:
auto getBitWidth() -> unsigned int override;
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