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.

142 lines
5.6KB

  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. //==============================================================================
  19. /**
  20. Reads and Writes WAV format audio files.
  21. @see AudioFormat
  22. */
  23. class JUCE_API WavAudioFormat : public AudioFormat
  24. {
  25. public:
  26. //==============================================================================
  27. /** Creates a format object. */
  28. WavAudioFormat();
  29. /** Destructor. */
  30. ~WavAudioFormat();
  31. //==============================================================================
  32. /** Metadata property name used by wav readers and writers for adding
  33. a BWAV chunk to the file.
  34. @see AudioFormatReader::metadataValues, createWriterFor
  35. */
  36. static const char* const bwavDescription;
  37. /** Metadata property name used by wav readers and writers for adding
  38. a BWAV chunk to the file.
  39. @see AudioFormatReader::metadataValues, createWriterFor
  40. */
  41. static const char* const bwavOriginator;
  42. /** Metadata property name used by wav readers and writers for adding
  43. a BWAV chunk to the file.
  44. @see AudioFormatReader::metadataValues, createWriterFor
  45. */
  46. static const char* const bwavOriginatorRef;
  47. /** Metadata property name used by wav readers and writers for adding
  48. a BWAV chunk to the file.
  49. Date format is: yyyy-mm-dd
  50. @see AudioFormatReader::metadataValues, createWriterFor
  51. */
  52. static const char* const bwavOriginationDate;
  53. /** Metadata property name used by wav readers and writers for adding
  54. a BWAV chunk to the file.
  55. Time format is: hh-mm-ss
  56. @see AudioFormatReader::metadataValues, createWriterFor
  57. */
  58. static const char* const bwavOriginationTime;
  59. /** Metadata property name used by wav readers and writers for adding
  60. a BWAV chunk to the file.
  61. This is the number of samples from the start of an edit that the
  62. file is supposed to begin at. Seems like an obvious mistake to
  63. only allow a file to occur in an edit once, but that's the way
  64. it is..
  65. @see AudioFormatReader::metadataValues, createWriterFor
  66. */
  67. static const char* const bwavTimeReference;
  68. /** Metadata property name used by wav readers and writers for adding
  69. a BWAV chunk to the file.
  70. @see AudioFormatReader::metadataValues, createWriterFor
  71. */
  72. static const char* const bwavCodingHistory;
  73. /** Utility function to fill out the appropriate metadata for a BWAV file.
  74. This just makes it easier than using the property names directly, and it
  75. fills out the time and date in the right format.
  76. */
  77. static StringPairArray createBWAVMetadata (const String& description,
  78. const String& originator,
  79. const String& originatorRef,
  80. const Time& dateAndTime,
  81. const int64 timeReferenceSamples,
  82. const String& codingHistory);
  83. //==============================================================================
  84. Array<int> getPossibleSampleRates();
  85. Array<int> getPossibleBitDepths();
  86. bool canDoStereo();
  87. bool canDoMono();
  88. //==============================================================================
  89. AudioFormatReader* createReaderFor (InputStream* sourceStream,
  90. bool deleteStreamIfOpeningFails);
  91. AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
  92. double sampleRateToUse,
  93. unsigned int numberOfChannels,
  94. int bitsPerSample,
  95. const StringPairArray& metadataValues,
  96. int qualityOptionIndex);
  97. //==============================================================================
  98. /** Utility function to replace the metadata in a wav file with a new set of values.
  99. If possible, this cheats by overwriting just the metadata region of the file, rather
  100. than by copying the whole file again.
  101. */
  102. bool replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata);
  103. private:
  104. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WavAudioFormat);
  105. };