b3ReadWavFile.h 985 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef B3_READ_WAV_FILE_H
  2. #define B3_READ_WAV_FILE_H
  3. #include "Bullet3Common/b3AlignedObjectArray.h"
  4. #include <stdio.h>
  5. #include <string.h>
  6. struct b3WavTicker
  7. {
  8. b3AlignedObjectArray<double> lastFrame_;
  9. bool finished_;
  10. double time_;
  11. double rate_;
  12. };
  13. class b3ReadWavFile
  14. {
  15. bool byteswap_;
  16. bool wavFile_;
  17. unsigned long m_numFrames;
  18. unsigned long dataType_;
  19. double fileDataRate_;
  20. FILE *fd_;
  21. unsigned long dataOffset_;
  22. unsigned int channels_;
  23. bool m_machineIsLittleEndian;
  24. public:
  25. b3ReadWavFile();
  26. virtual ~b3ReadWavFile();
  27. b3AlignedObjectArray<double> m_frames;
  28. bool getWavInfo(const char *fileName);
  29. void normalize(double peak);
  30. double interpolate(double frame, unsigned int channel) const;
  31. double tick(unsigned int channel, b3WavTicker *ticker);
  32. void resize();
  33. b3WavTicker createWavTicker(double sampleRate);
  34. bool read(unsigned long startFrame, bool doNormalize);
  35. int getNumFrames() const
  36. {
  37. return m_numFrames;
  38. }
  39. };
  40. #endif //B3_READ_WAV_FILE_H