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.

172 lines
7.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. //==============================================================================
  18. /**
  19. Reads and Writes WAV format audio files.
  20. @see AudioFormat
  21. */
  22. class JUCE_API WavAudioFormat : public AudioFormat
  23. {
  24. public:
  25. //==============================================================================
  26. /** Creates a format object. */
  27. WavAudioFormat();
  28. /** Destructor. */
  29. ~WavAudioFormat();
  30. //==============================================================================
  31. /** Metadata property name used by wav readers and writers for adding
  32. a BWAV chunk to the file.
  33. @see AudioFormatReader::metadataValues, createWriterFor
  34. */
  35. static const char* const bwavDescription;
  36. /** Metadata property name used by wav readers and writers for adding
  37. a BWAV chunk to the file.
  38. @see AudioFormatReader::metadataValues, createWriterFor
  39. */
  40. static const char* const bwavOriginator;
  41. /** Metadata property name used by wav readers and writers for adding
  42. a BWAV chunk to the file.
  43. @see AudioFormatReader::metadataValues, createWriterFor
  44. */
  45. static const char* const bwavOriginatorRef;
  46. /** Metadata property name used by wav readers and writers for adding
  47. a BWAV chunk to the file.
  48. Date format is: yyyy-mm-dd
  49. @see AudioFormatReader::metadataValues, createWriterFor
  50. */
  51. static const char* const bwavOriginationDate;
  52. /** Metadata property name used by wav readers and writers for adding
  53. a BWAV chunk to the file.
  54. Time format is: hh-mm-ss
  55. @see AudioFormatReader::metadataValues, createWriterFor
  56. */
  57. static const char* const bwavOriginationTime;
  58. /** Metadata property name used by wav readers and writers for adding
  59. a BWAV chunk to the file.
  60. This is the number of samples from the start of an edit that the
  61. file is supposed to begin at. Seems like an obvious mistake to
  62. only allow a file to occur in an edit once, but that's the way
  63. it is..
  64. @see AudioFormatReader::metadataValues, createWriterFor
  65. */
  66. static const char* const bwavTimeReference;
  67. /** Metadata property name used by wav readers and writers for adding
  68. a BWAV chunk to the file.
  69. @see AudioFormatReader::metadataValues, createWriterFor
  70. */
  71. static const char* const bwavCodingHistory;
  72. /** Utility function to fill out the appropriate metadata for a BWAV file.
  73. This just makes it easier than using the property names directly, and it
  74. fills out the time and date in the right format.
  75. */
  76. static StringPairArray createBWAVMetadata (const String& description,
  77. const String& originator,
  78. const String& originatorRef,
  79. const Time dateAndTime,
  80. const int64 timeReferenceSamples,
  81. const String& codingHistory);
  82. //==============================================================================
  83. /** Metadata property name used when reading a WAV file with an acid chunk. */
  84. static const char* const acidOneShot;
  85. /** Metadata property name used when reading a WAV file with an acid chunk. */
  86. static const char* const acidRootSet;
  87. /** Metadata property name used when reading a WAV file with an acid chunk. */
  88. static const char* const acidStretch;
  89. /** Metadata property name used when reading a WAV file with an acid chunk. */
  90. static const char* const acidDiskBased;
  91. /** Metadata property name used when reading a WAV file with an acid chunk. */
  92. static const char* const acidizerFlag;
  93. /** Metadata property name used when reading a WAV file with an acid chunk. */
  94. static const char* const acidRootNote;
  95. /** Metadata property name used when reading a WAV file with an acid chunk. */
  96. static const char* const acidBeats;
  97. /** Metadata property name used when reading a WAV file with an acid chunk. */
  98. static const char* const acidDenominator;
  99. /** Metadata property name used when reading a WAV file with an acid chunk. */
  100. static const char* const acidNumerator;
  101. /** Metadata property name used when reading a WAV file with an acid chunk. */
  102. static const char* const acidTempo;
  103. //==============================================================================
  104. /** Metadata property name used when reading an ISRC code from an AXML chunk. */
  105. static const char* const ISRC;
  106. /** Metadata property name used when reading a WAV file with a Tracktion chunk. */
  107. static const char* const tracktionLoopInfo;
  108. //==============================================================================
  109. Array<int> getPossibleSampleRates() override;
  110. Array<int> getPossibleBitDepths() override;
  111. bool canDoStereo() override;
  112. bool canDoMono() override;
  113. //==============================================================================
  114. AudioFormatReader* createReaderFor (InputStream* sourceStream,
  115. bool deleteStreamIfOpeningFails) override;
  116. MemoryMappedAudioFormatReader* createMemoryMappedReader (const File& file) override;
  117. AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
  118. double sampleRateToUse,
  119. unsigned int numberOfChannels,
  120. int bitsPerSample,
  121. const StringPairArray& metadataValues,
  122. int qualityOptionIndex) override;
  123. //==============================================================================
  124. /** Utility function to replace the metadata in a wav file with a new set of values.
  125. If possible, this cheats by overwriting just the metadata region of the file, rather
  126. than by copying the whole file again.
  127. */
  128. bool replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata);
  129. private:
  130. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WavAudioFormat)
  131. };