Change copyright date.
[asdcplib.git] / src / Wav.h
index a04c92f5a5406920c6596e2fb5354aae1d11cb84..f7d9df8902f027dca33e8482c37df868fee2628e 100755 (executable)
--- a/src/Wav.h
+++ b/src/Wav.h
@@ -32,14 +32,11 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef _WAV_H_
 #define _WAV_H_
 
-#include <FileIO.h>
+#include <KM_fileio.h>
+#include <AS_DCP.h>
 
 namespace ASDCP
 {
-namespace Wav
-{
-  const ui32_t MaxWavHeader = 1024*32; // must find "data" within this space or no happy
-
   //
   class fourcc
     {
@@ -55,37 +52,72 @@ namespace Wav
       inline bool operator!=(const fourcc &rhs)  { return memcmp(data, rhs.data, 4) != 0 ? true : false; }
     };
 
-  const fourcc FCC_RIFF("RIFF");
-  const fourcc FCC_WAVE("WAVE");
-  const fourcc FCC_fmt_("fmt ");
-  const fourcc FCC_data("data");
+  namespace AIFF
+    {
+      const fourcc FCC_FORM("FORM");
+      const fourcc FCC_AIFF("AIFF");
+      const fourcc FCC_COMM("COMM");
+      const fourcc FCC_SSND("SSND");
 
-  //
-  class SimpleWaveHeader
+      class SimpleAIFFHeader
+       {
+       public:
+         ui16_t  numChannels;
+         ui32_t  numSampleFrames;
+         ui16_t  sampleSize;
+         byte_t  sampleRate[10]; // 80-bit IEEE 754 float
+         ui32_t  data_len;
+
+         SimpleAIFFHeader() :
+           numChannels(0), numSampleFrames(0), sampleSize(0), data_len(0) {
+           memset(sampleRate, 0, 10);
+         }
+         
+         Result_t  ReadFromBuffer(const byte_t* buf, ui32_t buf_len, ui32_t* data_start);
+         Result_t  ReadFromFile(const Kumu::FileReader& InFile, ui32_t* data_start);
+         void      FillADesc(ASDCP::PCM::AudioDescriptor& ADesc, Rational PictureRate) const;
+       };
+
+    } // namespace AIFF
+
+  namespace Wav
     {
-    public:
-      ui16_t   format;
-      ui16_t   nchannels;
-      ui32_t   samplespersec;
-      ui32_t   avgbps;
-      ui16_t   blockalign;
-      ui16_t   bitspersample;
-      ui16_t   cbsize;
-      ui32_t   data_len;
-
-      SimpleWaveHeader() :
-       format(0), nchannels(0), samplespersec(0), avgbps(0),
-       blockalign(0), bitspersample(0), cbsize(0), data_len(0) {}
-      
-      SimpleWaveHeader(ASDCP::PCM::AudioDescriptor& ADesc);
+      const ui32_t MaxWavHeader = 1024*32; // must find "data" within this space or no happy
+
+      const fourcc FCC_RIFF("RIFF");
+      const fourcc FCC_WAVE("WAVE");
+      const fourcc FCC_fmt_("fmt ");
+      const fourcc FCC_data("data");
 
-      Result_t  ReadFromBuffer(const byte_t* buf, ui32_t buf_len, ui32_t* data_start);
-      Result_t  ReadFromFile(const ASDCP::FileReader& InFile, ui32_t* data_start);
-      Result_t  WriteToFile(ASDCP::FileWriter& OutFile) const;
-      void      FillADesc(ASDCP::PCM::AudioDescriptor& ADesc, Rational PictureRate) const;
-   };
+      const ui16_t WAVE_FORMAT_PCM = 1;
+      const ui16_t WAVE_FORMAT_EXTENSIBLE = 65534;
+
+      //
+      class SimpleWaveHeader
+       {
+       public:
+         ui16_t        format;
+         ui16_t        nchannels;
+         ui32_t        samplespersec;
+         ui32_t        avgbps;
+         ui16_t        blockalign;
+         ui16_t        bitspersample;
+         ui16_t        cbsize;
+         ui32_t        data_len;
+
+         SimpleWaveHeader() :
+           format(0), nchannels(0), samplespersec(0), avgbps(0),
+           blockalign(0), bitspersample(0), cbsize(0), data_len(0) {}
+      
+         SimpleWaveHeader(ASDCP::PCM::AudioDescriptor& ADesc);
+         
+         Result_t  ReadFromBuffer(const byte_t* buf, ui32_t buf_len, ui32_t* data_start);
+         Result_t  ReadFromFile(const Kumu::FileReader& InFile, ui32_t* data_start);
+         Result_t  WriteToFile(Kumu::FileWriter& OutFile) const;
+         void      FillADesc(ASDCP::PCM::AudioDescriptor& ADesc, Rational PictureRate) const;
+       };
 
-} // namespace Wav
+    } // namespace Wav
 } // namespace ASDCP
 
 #endif // _WAV_H_