wav.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* ------------------------------------------------------------------
  2. * Copyright (C) 2009 Martin Storsjo
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied.
  14. * See the License for the specific language governing permissions
  15. * and limitations under the License.
  16. * -------------------------------------------------------------------
  17. */
  18. #ifndef WAV_H
  19. #define WAV_H
  20. #include <stdio.h>
  21. class WavWriter {
  22. public:
  23. WavWriter(const char *filename, int sampleRate, int bitsPerSample, int channels);
  24. ~WavWriter();
  25. void writeData(const unsigned char* data, int length);
  26. private:
  27. void writeString(const char *str);
  28. void writeInt32(int value);
  29. void writeInt16(int value);
  30. void writeHeader(int length);
  31. FILE *wav;
  32. int dataLength;
  33. int sampleRate;
  34. int bitsPerSample;
  35. int channels;
  36. };
  37. #endif