home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bwavefilewriter.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  1.8 KB  |  79 lines

  1. /*
  2.  *
  3.  * $Id: k3bwavefilewriter.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BWAVEFILEWRITER_H
  18. #define K3BWAVEFILEWRITER_H
  19.  
  20. #include <qstring.h>
  21. #include <qfile.h>
  22. #include <qdatastream.h>
  23. #include "k3b_export.h"
  24. /**
  25.  * @author Sebastian Trueg
  26.  * Creates wave files from 16bit stereo little or big endian
  27.  * sound samples
  28.  */
  29. class LIBK3B_EXPORT K3bWaveFileWriter 
  30. {
  31.  public: 
  32.  
  33.   enum Endianess { BigEndian, LittleEndian };
  34.  
  35.   K3bWaveFileWriter();
  36.   ~K3bWaveFileWriter();
  37.  
  38.   /**
  39.    * open a new wave file.
  40.    * closes any opened file.
  41.    */
  42.   bool open( const QString& filename );
  43.  
  44.   bool isOpen();
  45.   const QString& filename() const;
  46.  
  47.   /**
  48.    * closes the file.
  49.    * Length of the wave file will be written into the header.
  50.    * If no data has been written to the file except the header
  51.    * it will be removed.
  52.    */
  53.   void close();
  54.  
  55.   /**
  56.    * write 16bit samples to the file.
  57.    * @param e the endianess of the data
  58.    *          (it will be swapped to little endian byte order if necessary)
  59.    */
  60.   void write( const char* data, int len, Endianess e = BigEndian );
  61.  
  62.   /**
  63.    * returnes a filedescriptor with the already opened file
  64.    * or -1 if isOpen() is false
  65.    */
  66.   int fd() const;
  67.  
  68.  private:
  69.   void writeEmptyHeader();
  70.   void updateHeader();
  71.   void padTo2352();
  72.  
  73.   QFile m_outputFile;
  74.   QDataStream m_outputStream;
  75.   QString m_filename;
  76. };
  77.  
  78. #endif
  79.