PTLib
Version 2.10.4
|
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: 21788 $ 00030 * $Author: rjongbloed $ 00031 * $Date: 2008-12-11 23:42:13 -0600 (Thu, 11 Dec 2008) $ 00032 */ 00033 00034 #ifndef PTLIB_PWAVFILEDEV_H 00035 #define PTLIB_PWAVFILEDEV_H 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( 00068 const PString & device, 00069 Directions dir, 00070 unsigned numChannels, 00071 unsigned sampleRate, 00072 unsigned bitsPerSample 00073 ); 00074 virtual PString GetName() const; 00075 PBoolean Close(); 00076 PBoolean IsOpen() const; 00077 PBoolean Write(const void * buf, PINDEX len); 00078 PBoolean Read(void * buf, PINDEX len); 00079 PBoolean SetFormat(unsigned numChannels, 00080 unsigned sampleRate, 00081 unsigned bitsPerSample); 00082 unsigned GetChannels() const; 00083 unsigned GetSampleRate() const; 00084 unsigned GetSampleSize() const; 00085 PBoolean SetBuffers(PINDEX size, PINDEX count); 00086 PBoolean GetBuffers(PINDEX & size, PINDEX & count); 00087 PBoolean HasPlayCompleted(); 00088 PBoolean WaitForPlayCompletion(); 00089 PBoolean StartRecording(); 00090 PBoolean IsRecordBufferFull(); 00091 PBoolean AreAllRecordBuffersFull(); 00092 PBoolean WaitForRecordBufferFull(); 00093 PBoolean WaitForAllRecordBuffersFull(); 00094 00095 protected: 00096 bool ReadSamples(void * data, PINDEX size); 00097 00098 PWAVFile m_WAVFile; 00099 PAdaptiveDelay m_Pacing; 00100 bool m_autoRepeat; 00101 unsigned m_sampleRate; 00102 PINDEX m_bufferSize; 00103 }; 00104 00105 00106 #endif // defined(P_WAVFILE) 00107 00108 #endif // PTLIB_PWAVFILEDEV_H 00109 00110 00111 // End Of File ///////////////////////////////////////////////////////////////