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  * $Log: pwavfiledev.h,v $
00030  * Revision 1.2  2007/10/09 02:35:39  rjongbloed
00031  * Added ability to make WAV file audio record device auto repeat the WAV file
00032  *   when reach end of file, signaled by appending an '*' to end of filename.
00033  *
00034  * Revision 1.1  2007/04/13 07:03:20  rjongbloed
00035  * Added WAV file audio device "plug in".
00036  *
00037  */
00038 
00039 #ifndef _PWAVFILEDEV
00040 #define _PWAVFILEDEV
00041 
00042 #ifdef P_USE_PRAGMA
00043 #pragma interface
00044 #endif
00045 
00046 #include <ptlib.h>
00047 
00048 #include <ptlib/sound.h>
00049 #include <ptclib/pwavfile.h>
00050 #include <ptclib/delaychan.h>
00051 
00052 #if defined(P_WAVFILE)
00053 
00054 
00056 //
00057 // This class defines a sound channel device that reads audio from a raw WAV file
00058 //
00059 
00060 class PSoundChannel_WAVFile : public PSoundChannel
00061 {
00062  PCLASSINFO(PSoundChannel_WAVFile, PSoundChannel);
00063  public:
00064     PSoundChannel_WAVFile();
00065     PSoundChannel_WAVFile(const PString &device,
00066                      PSoundChannel::Directions dir,
00067                      unsigned numChannels,
00068                      unsigned sampleRate,
00069                      unsigned bitsPerSample);
00070     ~PSoundChannel_WAVFile();
00071     static PStringArray GetDeviceNames(PSoundChannel::Directions = Player);
00072     BOOL Open(const PString & _device,
00073               Directions _dir,
00074               unsigned _numChannels,
00075               unsigned _sampleRate,
00076               unsigned _bitsPerSample);
00077     virtual PString GetName() const;
00078     BOOL Close();
00079     BOOL IsOpen() const;
00080     BOOL Write(const void * buf, PINDEX len);
00081     BOOL Read(void * buf, PINDEX len);
00082     BOOL SetFormat(unsigned numChannels,
00083                    unsigned sampleRate,
00084                    unsigned bitsPerSample);
00085     unsigned GetChannels() const;
00086     unsigned GetSampleRate() const;
00087     unsigned GetSampleSize() const;
00088     BOOL SetBuffers(PINDEX size, PINDEX count);
00089     BOOL GetBuffers(PINDEX & size, PINDEX & count);
00090     BOOL HasPlayCompleted();
00091     BOOL WaitForPlayCompletion();
00092     BOOL StartRecording();
00093     BOOL IsRecordBufferFull();
00094     BOOL AreAllRecordBuffersFull();
00095     BOOL WaitForRecordBufferFull();
00096     BOOL WaitForAllRecordBuffersFull();
00097 
00098 protected:
00099     PWAVFile       m_WAVFile;
00100     PAdaptiveDelay m_Pacing;
00101     bool           m_autoRepeat;
00102 };
00103 
00104 
00105 #endif // defined(P_WAVFILE)
00106 
00107 #endif // _PWAVFILEDEV
00108 

Generated on Fri Mar 7 06:25:02 2008 for PTLib by  doxygen 1.5.1