sipxmedialib  Version 3.3
MpSineWaveGeneratorDeviceDriver.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007-2008 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2007-2008 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // $$
10 
11 // Author: Dan Petrie <dpetrie AT SIPez DOT com>
12 
13 #ifndef _MpSineWaveGeneratorDeviceDriver_h_
14 #define _MpSineWaveGeneratorDeviceDriver_h_
15 
16 // SYSTEM INCLUDES
17 #include <utl/UtlDefs.h>
18 #include <os/OsStatus.h>
19 #include <utl/UtlString.h>
20 #include <mp/MpInputDeviceDriver.h>
21 
22 // APPLICATION INCLUDES
23 #include "mp/MpTypes.h"
24 
25 // DEFINES
26 // MACROS
27 // EXTERNAL FUNCTIONS
28 // EXTERNAL VARIABLES
29 // CONSTANTS
30 // STRUCTS
31 // TYPEDEFS
32 // FORWARD DECLARATIONS
34 class OsServerTask;
35 
46 {
47 /* //////////////////////////// PUBLIC //////////////////////////////////// */
48 public:
49 
50 /* ============================ CREATORS ================================== */
52 
53 
55  MpSineWaveGeneratorDeviceDriver(const UtlString& name,
56  MpInputDeviceManager& deviceManager,
57  unsigned int magnitude,
58  unsigned int periodInMicroseconds,
59  int relativeSpeed);
76  virtual
79 
81 
82 /* ============================ MANIPULATORS ============================== */
84 
85  virtual OsStatus enableDevice(unsigned samplesPerFrame,
87  unsigned samplesPerSec,
88  MpFrameTime currentFrameTime);
101  virtual OsStatus disableDevice();
111  virtual OsStatus setTone(unsigned int periodInMicroseconds);
113 
115  virtual OsStatus setMagnitude(unsigned int magnitude);
117 
118 /* ============================ ACCESSORS ================================= */
120 
121 
122 
124  static MpAudioSample calculateSample(MpFrameTime frameStartTime,
125  unsigned int magnitude,
126  unsigned int periodInMicroseconds,
127  unsigned int frameSampleIndex,
128  unsigned int samplesPerFrame,
129  unsigned int samplesPerSecond);
144 
145 /* ============================ INQUIRY =================================== */
147 
148 
150  inline UtlBoolean isDeviceValid();
151 
152 
154 
155 /* //////////////////////////// PROTECTED ///////////////////////////////// */
156 protected:
157 
158 
159 /* //////////////////////////// PRIVATE /////////////////////////////////// */
160 private:
161 
163  MpSineWaveGeneratorDeviceDriver(const MpSineWaveGeneratorDeviceDriver& rMpSineWaveGeneratorDeviceDriver);
164 
167 
168  unsigned int mMagnitude;
169  unsigned int mPeriodInMicroseconds;
171  OsServerTask* mpReaderTask;
172 };
173 
174 /* ============================ INLINE METHODS ============================ */
175 
177 {
178  // This test driver is always valid.
179  return TRUE;
180 }
181 
182 #endif // _MpSineWaveGeneratorDeviceDriver_h_
OsServerTask * mpReaderTask
Definition: MpSineWaveGeneratorDeviceDriver.h:171
int samplesPerFrame
uint32_t MpFrameTime
Definition: MpTypes.h:53
static MpAudioSample calculateSample(MpFrameTime frameStartTime, unsigned int magnitude, unsigned int periodInMicroseconds, unsigned int frameSampleIndex, unsigned int samplesPerFrame, unsigned int samplesPerSecond)
Calculate a sample value for the specified sample in a frame.
Definition: MpSineWaveGeneratorDeviceDriver.cpp:278
UtlBoolean isDeviceValid()
Inquire if the device is valid.
Definition: MpSineWaveGeneratorDeviceDriver.h:176
unsigned int mPeriodInMicroseconds
Definition: MpSineWaveGeneratorDeviceDriver.h:169
int samplesPerSecond
virtual OsStatus setTone(unsigned int periodInMicroseconds)
Set a new tone to be played.
Definition: MpSineWaveGeneratorDeviceDriver.cpp:260
virtual ~MpSineWaveGeneratorDeviceDriver()
Destructor.
Definition: MpSineWaveGeneratorDeviceDriver.cpp:195
int16_t MpAudioSample
Definition: MpTypes.h:44
virtual OsStatus setMagnitude(unsigned int magnitude)
Set a new magnitude to be played.
Definition: MpSineWaveGeneratorDeviceDriver.cpp:268
Container of input devices for input drivers and resources.
Definition: MpInputDeviceManager.h:79
int mRelativeSpeed
Definition: MpSineWaveGeneratorDeviceDriver.h:170
virtual OsStatus enableDevice(unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime)
Initialize device driver and state.
Definition: MpSineWaveGeneratorDeviceDriver.cpp:208
MpSineWaveGeneratorDeviceDriver & operator=(const MpSineWaveGeneratorDeviceDriver &rhs)
Assignment operator (not implemented for this class)
unsigned int mMagnitude
Definition: MpSineWaveGeneratorDeviceDriver.h:168
Container for device specific input driver.
Definition: MpInputDeviceDriver.h:58
MpSineWaveGeneratorDeviceDriver(const UtlString &name, MpInputDeviceManager &deviceManager, unsigned int magnitude, unsigned int periodInMicroseconds, int relativeSpeed)
Default constructor.
Definition: MpSineWaveGeneratorDeviceDriver.cpp:181
virtual OsStatus disableDevice()
Uninitialize device driver.
Definition: MpSineWaveGeneratorDeviceDriver.cpp:242
#define TRUE
Definition: PlgDefsV1.h:41
Sine wave generator Input Device Driver.
Definition: MpSineWaveGeneratorDeviceDriver.h:45