pwavfiledev.h

Go to the documentation of this file.
00001 /*
00002  * pwavfiledev.cxx
00003  *
00004  * Sound file device declaration
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (C) 2007 Post Increment
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is
00023  * Robert Jongbloed <robertj@postincrement.com>
00024  *
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Revision: 20385 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
00032  */
00033 
00034 #ifndef _PWAVFILEDEV
00035 #define _PWAVFILEDEV
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 #include <ptlib.h>
00042 
00043 #include <ptlib/sound.h>
00044 #include <ptclib/pwavfile.h>
00045 #include <ptclib/delaychan.h>
00046 
00047 #if defined(P_WAVFILE)
00048 
00049 
00051 //
00052 // This class defines a sound channel device that reads audio from a raw WAV file
00053 //
00054 
00055 class PSoundChannel_WAVFile : public PSoundChannel
00056 {
00057  PCLASSINFO(PSoundChannel_WAVFile, PSoundChannel);
00058  public:
00059     PSoundChannel_WAVFile();
00060     PSoundChannel_WAVFile(const PString &device,
00061                      PSoundChannel::Directions dir,
00062                      unsigned numChannels,
00063                      unsigned sampleRate,
00064                      unsigned bitsPerSample);
00065     ~PSoundChannel_WAVFile();
00066     static PStringArray GetDeviceNames(PSoundChannel::Directions = Player);
00067     PBoolean Open(const PString & _device,
00068               Directions _dir,
00069               unsigned _numChannels,
00070               unsigned _sampleRate,
00071               unsigned _bitsPerSample);
00072     virtual PString GetName() const;
00073     PBoolean Close();
00074     PBoolean IsOpen() const;
00075     PBoolean Write(const void * buf, PINDEX len);
00076     PBoolean Read(void * buf, PINDEX len);
00077     PBoolean SetFormat(unsigned numChannels,
00078                    unsigned sampleRate,
00079                    unsigned bitsPerSample);
00080     unsigned GetChannels() const;
00081     unsigned GetSampleRate() const;
00082     unsigned GetSampleSize() const;
00083     PBoolean SetBuffers(PINDEX size, PINDEX count);
00084     PBoolean GetBuffers(PINDEX & size, PINDEX & count);
00085     PBoolean HasPlayCompleted();
00086     PBoolean WaitForPlayCompletion();
00087     PBoolean StartRecording();
00088     PBoolean IsRecordBufferFull();
00089     PBoolean AreAllRecordBuffersFull();
00090     PBoolean WaitForRecordBufferFull();
00091     PBoolean WaitForAllRecordBuffersFull();
00092 
00093 protected:
00094     bool ReadSamples(void * data, PINDEX size);
00095 
00096     PWAVFile       m_WAVFile;
00097     PAdaptiveDelay m_Pacing;
00098     bool           m_autoRepeat;
00099     unsigned       m_sampleRate;
00100     PINDEX         m_bufferSize;
00101 };
00102 
00103 
00104 #endif // defined(P_WAVFILE)
00105 
00106 #endif // _PWAVFILEDEV
00107 

Generated on Mon Feb 23 01:57:54 2009 for PTLib by  doxygen 1.5.1