PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pwavfiledev.h
Go to the documentation of this file.
1 /*
2 * pwavfiledev.cxx
3 *
4 * Sound file device declaration
5 *
6 * Portable Windows Library
7 *
8 * Copyright (C) 2007 Post Increment
9 *
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
14 *
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * The Original Code is Portable Windows Library.
21 *
22 * The Initial Developer of the Original Code is
23 * Robert Jongbloed <robertj@postincrement.com>
24 *
25 * All Rights Reserved.
26 *
27 * Contributor(s): ______________________________________.
28 *
29 * $Revision: 27469 $
30 * $Author: rjongbloed $
31 * $Date: 2012-04-19 05:33:35 +1000 (Thu, 19 Apr 2012) $
32 */
33
34 #ifndef PTLIB_PWAVFILEDEV_H
35 #define PTLIB_PWAVFILEDEV_H
36
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40
41 #include <ptlib.h>
42
43 #include <ptlib/sound.h>
44 #include <ptclib/pwavfile.h>
45 #include <ptclib/delaychan.h>
46
47 #if defined(P_WAVFILE)
48
49
51 //
52 // This class defines a sound channel device that reads audio from a raw WAV file
53 //
54
55 class PSoundChannel_WAVFile : public PSoundChannel
56 {
57 PCLASSINFO(PSoundChannel_WAVFile, PSoundChannel);
58 public:
59 PSoundChannel_WAVFile();
60 PSoundChannel_WAVFile(const PString &device,
61 PSoundChannel::Directions dir,
62 unsigned numChannels,
63 unsigned sampleRate,
64 unsigned bitsPerSample);
65 ~PSoundChannel_WAVFile();
66 static PStringArray GetDeviceNames(PSoundChannel::Directions = Player);
67 PBoolean Open(
68 const PString & device,
69 Directions dir,
70 unsigned numChannels,
71 unsigned sampleRate,
72 unsigned bitsPerSample
73 );
74 virtual PString GetName() const;
75 PBoolean Close();
76 PBoolean IsOpen() const;
77 PBoolean Write(const void * buf, PINDEX len);
78 PBoolean Read(void * buf, PINDEX len);
79 PBoolean SetFormat(unsigned numChannels,
80 unsigned sampleRate,
81 unsigned bitsPerSample);
82 unsigned GetChannels() const;
83 unsigned GetSampleRate() const;
84 unsigned GetSampleSize() const;
85 PBoolean SetBuffers(PINDEX size, PINDEX count);
86 PBoolean GetBuffers(PINDEX & size, PINDEX & count);
87 PBoolean HasPlayCompleted();
88 PBoolean WaitForPlayCompletion();
89 PBoolean StartRecording();
90 PBoolean IsRecordBufferFull();
91 PBoolean AreAllRecordBuffersFull();
92 PBoolean WaitForRecordBufferFull();
93 PBoolean WaitForAllRecordBuffersFull();
94
95 protected:
96 bool ReadSamples(void * data, PINDEX size);
97 bool ReadSample(short & data);
98
99 PWAVFile m_WAVFile;
100 PAdaptiveDelay m_Pacing;
101 bool m_autoRepeat;
102 unsigned m_sampleRate;
103 PINDEX m_bufferSize;
104 PShortArray m_sampleBuffer;
105 PINDEX m_samplePosition;
106 };
107
108
109 #endif // defined(P_WAVFILE)
110
111 #endif // PTLIB_PWAVFILEDEV_H
112
113
114 // End Of File ///////////////////////////////////////////////////////////////