Line data Source code
1 : /** 2 : * \file WavStruct.h 3 : */ 4 : 5 : #ifndef ATK_IO_WAVSTRUCT_H 6 : #define ATK_IO_WAVSTRUCT_H 7 : 8 : #include <cstdint> 9 : 10 : namespace ATK 11 : { 12 : /// Standard Wav header block 13 : struct WavHeader 14 : { 15 : char FileTypeBlocID[4]; 16 : std::int32_t FileSize; 17 : char FileFormatID[4]; 18 : }; 19 : 20 : /// Standard Wav format block 21 : struct WavFormat 22 : { 23 : char FormatBlocID[4]; 24 : std::int32_t BlocSize; 25 : std::int16_t AudioFormat; 26 : std::int16_t NbChannels; 27 : std::int32_t Frequence; 28 : std::int32_t BytePerSec; 29 : std::int16_t BytePerBloc; 30 : std::int16_t BitsPerSample; 31 : }; 32 : 33 : /// Standard Wav data block 34 : struct WavData 35 : { 36 : char DataBlocID[4]; 37 : std::int32_t DataSize; 38 : }; 39 : 40 : /// Empty traits 41 : template<typename DataType> 42 : class WavTraits 43 : { 44 : }; 45 : 46 : /// Traits for integer 16bits 47 : template<> 48 : class WavTraits<std::int16_t> 49 : { 50 : public: 51 : static int get_wav_type() 52 : { 53 : return 1; 54 : } 55 : }; 56 : 57 : /// Traits for float 32bits 58 : template<> 59 : class WavTraits<float> 60 : { 61 : public: 62 7 : static int get_wav_type() 63 : { 64 7 : return 3; 65 : } 66 : }; 67 : 68 : /// Traits for double 64bits 69 : template<> 70 : class WavTraits<double> 71 : { 72 : public: 73 : static int get_wav_type() 74 : { 75 : return 3; 76 : } 77 : }; 78 : } 79 : 80 : #endif