cAudio  2.3.0
3d Audio Engine
IAudioCapture.h
1 // Copyright (c) 2008-2011 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones, Murat (wolfmanfx) Sari
2 // This file is part of the "cAudio Engine"
3 // For conditions of distribution and use, see copyright notice in cAudio.h
4 
5 #pragma once
6 
7 #include "EAudioFormats.h"
8 #include "cAudioDefines.h"
9 #include "ICaptureEventHandler.h"
10 
11 namespace cAudio
12 {
13  // Is responsible to create/destroy a capture buffer
14  class AudioCaptureBuffer;
15 
18  {
19  public:
20  IAudioCapture() { }
21  virtual ~IAudioCapture() { }
22 
24 
31  virtual bool initialize(const char* deviceName = 0x0, unsigned int frequency = 22050, AudioFormats format = EAF_16BIT_MONO, unsigned int internalBufferSize = 8192) = 0;
32 
34  virtual bool isReady() = 0;
36 
37  virtual void updateCaptureBuffer(bool force = false) = 0;
39  virtual void shutdown() = 0;
40 
42 
46  virtual bool isUpdateThreadRunning() = 0;
47 
49  virtual const char* getDeviceName() = 0;
51  virtual unsigned int getFrequency() = 0;
53  virtual AudioFormats getFormat() = 0;
55 
56  virtual unsigned int getInternalBufferSize() = 0;
58 
59  virtual unsigned int getSampleSize() = 0;
60 
62 
65  virtual bool setDevice(const char* deviceName) = 0;
67 
70  virtual bool setFrequency(unsigned int frequency) = 0;
72 
75  virtual bool setFormat(AudioFormats format) = 0;
77 
80  virtual bool setInternalBufferSize(unsigned int internalBufferSize) = 0;
81 
83 
84  virtual bool beginCapture() = 0;
86  virtual void stopCapture() = 0;
88 
94  virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize) = 0;
95 
98 
100  virtual unsigned int getCurrentCapturedAudioSize() = 0;
101 
103 
104  virtual void registerEventHandler(ICaptureEventHandler* handler) = 0;
106 
107  virtual void unRegisterEventHandler(ICaptureEventHandler* handler) = 0;
109  virtual void unRegisterAllEventHandlers() = 0;
110  };
111 
112  // Is responsible to create/destroy a capture buffer
114  {
115  public:
116  AudioCaptureBuffer(size_t inlength)
117  {
118  length = inlength;
119  buffer = new char[length];
120  }
121 
123  {
124  buffer = p.buffer;
125  length = p.length;
126  }
127 
129  {
130  delete buffer;
131  buffer = NULL;
132  }
133 
134  const char* getReadBuffer() const
135  {
136  return buffer;
137  }
138 
139  char* getWriteBuffer()
140  {
141  return buffer;
142  }
143 
144  size_t getLength() const
145  {
146  return length;
147  }
148 
149  private:
150  char* buffer;
151  size_t length;
152  };
153 };
cAudio::AudioFormats
AudioFormats
Enumeration of audio formats supported by the engine.
Definition: EAudioFormats.h:10
cAudio::IAudioCapture::setFormat
virtual bool setFormat(AudioFormats format)=0
Sets the format that the captured audio will be at. Will cause the capture device to be reinitialized...
cAudio::IAudioCapture::getSampleSize
virtual unsigned int getSampleSize()=0
Returns the size of a "sample" of audio data. Useful for making sure you grab audio data at sample bo...
cAudio::IAudioCapture::shutdown
virtual void shutdown()=0
Shuts down the capture device, clearing the internal buffer and setting the audio capture into an uni...
cAudio::IAudioCapture::registerEventHandler
virtual void registerEventHandler(ICaptureEventHandler *handler)=0
Registers a new event handler to this manager.
cAudio::IAudioCapture::isUpdateThreadRunning
virtual bool isUpdateThreadRunning()=0
Returns if the thread used to update all Audio Capture Objects is running.
cAudio::IAudioCapture
Interface for capturing operations in the cAudio Engine.
Definition: IAudioCapture.h:17
cAudio::IAudioCapture::initialize
virtual bool initialize(const char *deviceName=0x0, unsigned int frequency=22050, AudioFormats format=EAF_16BIT_MONO, unsigned int internalBufferSize=8192)=0
Initializes the capture device to the selected settings.
cAudio
Main namespace for the entire cAudio library.
Definition: cAudioCapture.h:15
cAudio::ICaptureEventHandler
Interface for recieving Capture Manager Events.
Definition: ICaptureEventHandler.h:10
cAudio::IAudioCapture::beginCapture
virtual bool beginCapture()=0
Starts capturing audio data to an internal buffer. Will clear any old data in the buffer.
cAudio::IAudioCapture::getCapturedAudio
virtual unsigned int getCapturedAudio(void *outputBuffer, unsigned int outputBufferSize)=0
Allows access to the audio data in the internal capture buffer.
cAudio::IAudioCapture::setInternalBufferSize
virtual bool setInternalBufferSize(unsigned int internalBufferSize)=0
Sets the internal buffer size that OpenAL will use to store captured audio between calls to getCaptur...
cAudio::IAudioCapture::getCapturedAudioBuffer
virtual AudioCaptureBuffer * getCapturedAudioBuffer()=0
this method is the same as getCapturedAudio but it returns an managed CaptureBuffer
cAudio::IAudioCapture::unRegisterEventHandler
virtual void unRegisterEventHandler(ICaptureEventHandler *handler)=0
Removes the specified event handler from this manager.
cAudio::AudioCaptureBuffer
Definition: IAudioCapture.h:113
cAudio::IAudioCapture::getDeviceName
virtual const char * getDeviceName()=0
Returns the name of the audio device being used to capture audio.
cAudio::IAudioCapture::updateCaptureBuffer
virtual void updateCaptureBuffer(bool force=false)=0
Grabs samples from the OpenAL buffer into the capture buffer if the OpenAL buffer has reached half fu...
cAudio::IAudioCapture::getFormat
virtual AudioFormats getFormat()=0
Returns the format of the captured audio.
cAudio::IAudioCapture::stopCapture
virtual void stopCapture()=0
Stops capturing audio data to an internal buffer.
cAudio::IAudioCapture::getCurrentCapturedAudioSize
virtual unsigned int getCurrentCapturedAudioSize()=0
Returns the current size of the internal audio buffer in bytes.
cAudio::IAudioCapture::setDevice
virtual bool setDevice(const char *deviceName)=0
Sets the audio device . Will cause the capture device to be reinitialized. Calling while in use will ...
cAudio::IAudioCapture::setFrequency
virtual bool setFrequency(unsigned int frequency)=0
Sets the frequency that the captured audio will be at. Will cause the capture device to be reinitiali...
cAudio::IAudioCapture::getFrequency
virtual unsigned int getFrequency()=0
Returns the frequency that the captured audio will be at.
cAudio::IAudioCapture::isReady
virtual bool isReady()=0
Returns true if the capture device is ready to be used. False may indicate an error with the current ...
cAudio::IAudioCapture::unRegisterAllEventHandlers
virtual void unRegisterAllEventHandlers()=0
Removes all event handlers attached to this manager.
cAudio::IAudioCapture::getInternalBufferSize
virtual unsigned int getInternalBufferSize()=0
Returns the internal OpenAL buffer size in bytes.