43 lines
1021 B
C++
43 lines
1021 B
C++
#pragma once
|
|
#include"WavStruct.h"
|
|
#include <fstream>
|
|
class WavFileReader
|
|
{
|
|
public:
|
|
WavFileReader();
|
|
~WavFileReader();
|
|
|
|
bool OpenFile(const std::string& p_fileName);
|
|
void CloseFile();
|
|
int ReadData(char* p_buffer, int p_position, int p_readLength);
|
|
void SetPosition(int p_position);
|
|
int GetPosition();
|
|
int GetDataLength();
|
|
int GetFileLength();
|
|
int GetChannels();
|
|
int GetSampleRate();
|
|
int GetBitsPerSample();
|
|
float GetLastingTime();
|
|
int GetBytesPerSec();
|
|
int GetSampleNum();
|
|
int16_t GetSampleValue(int p_index);
|
|
private:
|
|
bool ProcessWavFile();
|
|
void ProcessSampleValue();
|
|
void ProcessLIST(int p_listLength);
|
|
void ProcessCustom();
|
|
void ProcessDATA();
|
|
private:
|
|
std::ifstream m_file;
|
|
uint32_t m_fileLength = 0;
|
|
uint32_t m_dataLength = 0;
|
|
uint32_t m_dataOffset = 0;
|
|
uint32_t m_channels = 0;
|
|
uint32_t m_sampleRate = 0;
|
|
uint32_t m_bitsPerSample = 0;
|
|
uint32_t m_bytesPerSec = 0;
|
|
float m_lastingTime = 0;
|
|
std::string m_fileName = "";
|
|
uint32_t m_sampleNum = 0;
|
|
uint64_t m_fileSize = 0;
|
|
}; |