cAudio 2.3.0
3d Audio Engine
Loading...
Searching...
No Matches
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
11namespace 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
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};
Interface for capturing operations in the cAudio Engine.
Definition: IAudioCapture.h:18
virtual void stopCapture()=0
Stops capturing audio data to an internal buffer.
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.
virtual AudioCaptureBuffer * getCapturedAudioBuffer()=0
this method is the same as getCapturedAudio but it returns an managed CaptureBuffer
virtual const char * getDeviceName()=0
Returns the name of the audio device being used to capture audio.
virtual void unRegisterAllEventHandlers()=0
Removes all event handlers attached to this manager.
virtual bool isReady()=0
Returns true if the capture device is ready to be used. False may indicate an error with the current ...
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...
virtual unsigned int getCapturedAudio(void *outputBuffer, unsigned int outputBufferSize)=0
Allows access to the audio data in the internal capture buffer.
virtual void registerEventHandler(ICaptureEventHandler *handler)=0
Registers a new event handler to this manager.
virtual unsigned int getCurrentCapturedAudioSize()=0
Returns the current size of the internal audio buffer in bytes.
virtual void unRegisterEventHandler(ICaptureEventHandler *handler)=0
Removes the specified event handler from this manager.
virtual AudioFormats getFormat()=0
Returns the format of the captured audio.
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...
virtual void shutdown()=0
Shuts down the capture device, clearing the internal buffer and setting the audio capture into an uni...
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...
virtual bool setDevice(const char *deviceName)=0
Sets the audio device . Will cause the capture device to be reinitialized. Calling while in use will ...
virtual bool isUpdateThreadRunning()=0
Returns if the thread used to update all Audio Capture Objects is running.
virtual bool setFormat(AudioFormats format)=0
Sets the format that the captured audio will be at. Will cause the capture device to be reinitialized...
virtual unsigned int getFrequency()=0
Returns the frequency that the captured audio will be at.
virtual bool beginCapture()=0
Starts capturing audio data to an internal buffer. Will clear any old data in the buffer.
virtual bool setInternalBufferSize(unsigned int internalBufferSize)=0
Sets the internal buffer size that OpenAL will use to store captured audio between calls to getCaptur...
virtual unsigned int getInternalBufferSize()=0
Returns the internal OpenAL buffer size in bytes.
Interface for recieving Capture Manager Events.
Main namespace for the entire cAudio library.
Definition: cAudioCapture.h:16
AudioFormats
Enumeration of audio formats supported by the engine.
Definition: EAudioFormats.h:11