The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
5.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__
  19. #define __JUCE_WAVAUDIOFORMAT_JUCEHEADER__
  20. #include "../format/juce_AudioFormat.h"
  21. //==============================================================================
  22. /**
  23. Reads and Writes WAV format audio files.
  24. @see AudioFormat
  25. */
  26. class JUCE_API WavAudioFormat : public AudioFormat
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a format object. */
  31. WavAudioFormat();
  32. /** Destructor. */
  33. ~WavAudioFormat();
  34. //==============================================================================
  35. /** Metadata property name used by wav readers and writers for adding
  36. a BWAV chunk to the file.
  37. @see AudioFormatReader::metadataValues, createWriterFor
  38. */
  39. static const char* const bwavDescription;
  40. /** Metadata property name used by wav readers and writers for adding
  41. a BWAV chunk to the file.
  42. @see AudioFormatReader::metadataValues, createWriterFor
  43. */
  44. static const char* const bwavOriginator;
  45. /** Metadata property name used by wav readers and writers for adding
  46. a BWAV chunk to the file.
  47. @see AudioFormatReader::metadataValues, createWriterFor
  48. */
  49. static const char* const bwavOriginatorRef;
  50. /** Metadata property name used by wav readers and writers for adding
  51. a BWAV chunk to the file.
  52. Date format is: yyyy-mm-dd
  53. @see AudioFormatReader::metadataValues, createWriterFor
  54. */
  55. static const char* const bwavOriginationDate;
  56. /** Metadata property name used by wav readers and writers for adding
  57. a BWAV chunk to the file.
  58. Time format is: hh-mm-ss
  59. @see AudioFormatReader::metadataValues, createWriterFor
  60. */
  61. static const char* const bwavOriginationTime;
  62. /** Metadata property name used by wav readers and writers for adding
  63. a BWAV chunk to the file.
  64. This is the number of samples from the start of an edit that the
  65. file is supposed to begin at. Seems like an obvious mistake to
  66. only allow a file to occur in an edit once, but that's the way
  67. it is..
  68. @see AudioFormatReader::metadataValues, createWriterFor
  69. */
  70. static const char* const bwavTimeReference;
  71. /** Metadata property name used by wav readers and writers for adding
  72. a BWAV chunk to the file.
  73. This is a
  74. @see AudioFormatReader::metadataValues, createWriterFor
  75. */
  76. static const char* const bwavCodingHistory;
  77. /** Utility function to fill out the appropriate metadata for a BWAV file.
  78. This just makes it easier than using the property names directly, and it
  79. fills out the time and date in the right format.
  80. */
  81. static StringPairArray createBWAVMetadata (const String& description,
  82. const String& originator,
  83. const String& originatorRef,
  84. const Time& dateAndTime,
  85. const int64 timeReferenceSamples,
  86. const String& codingHistory);
  87. //==============================================================================
  88. Array<int> getPossibleSampleRates();
  89. Array<int> getPossibleBitDepths();
  90. bool canDoStereo();
  91. bool canDoMono();
  92. //==============================================================================
  93. AudioFormatReader* createReaderFor (InputStream* sourceStream,
  94. bool deleteStreamIfOpeningFails);
  95. AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
  96. double sampleRateToUse,
  97. unsigned int numberOfChannels,
  98. int bitsPerSample,
  99. const StringPairArray& metadataValues,
  100. int qualityOptionIndex);
  101. //==============================================================================
  102. /** Utility function to replace the metadata in a wav file with a new set of values.
  103. If possible, this cheats by overwriting just the metadata region of the file, rather
  104. than by copying the whole file again.
  105. */
  106. bool replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata);
  107. private:
  108. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WavAudioFormat);
  109. };
  110. #endif // __JUCE_WAVAUDIOFORMAT_JUCEHEADER__