diff --git a/Samples/CSharpAudioPlayer/CSharpTutorial4_AudioCapture/CSharpTutorial4_AudioCapture.csproj b/Samples/CSharpAudioPlayer/CSharpTutorial4_AudioCapture/CSharpTutorial4_AudioCapture.csproj
index 8d2e036..248002f 100644
--- a/Samples/CSharpAudioPlayer/CSharpTutorial4_AudioCapture/CSharpTutorial4_AudioCapture.csproj
+++ b/Samples/CSharpAudioPlayer/CSharpTutorial4_AudioCapture/CSharpTutorial4_AudioCapture.csproj
@@ -38,6 +38,7 @@
DEBUG;TRACE
prompt
4
+ true
x86
diff --git a/Samples/CSharpAudioPlayer/CSharpTutorial4_AudioCapture/Program.cs b/Samples/CSharpAudioPlayer/CSharpTutorial4_AudioCapture/Program.cs
index 6a9e940..13d224f 100644
--- a/Samples/CSharpAudioPlayer/CSharpTutorial4_AudioCapture/Program.cs
+++ b/Samples/CSharpAudioPlayer/CSharpTutorial4_AudioCapture/Program.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Windows.Forms;
using cAudio;
@@ -99,15 +100,12 @@ namespace CSharpTutorial4_AudioCapture
//Grab the total size again, ensures we get ALL the audio data
//Not completely necessary, as starting a capture again will clear the old audio data
currentsize = capture.getCurrentCapturedAudioSize();
-
- //char[] buffer = new char[currentsize];
- string[] buffer = new string[currentsize];
-
- Console.WriteLine("Captured " + capture.getCapturedAudio(buffer, currentsize) + " bytes of audio data. \n ");
+ Console.WriteLine("Captured " + currentsize + " bytes of audio data. \n ");
//Create a IAudio object and load a sound from a file
-
- IAudioSource mysound = audioMgr.createFromRaw("sound1", Convert.ToString(buffer), currentsize, CAPTURE_FREQUENCY, CAPTURE_FORMAT);
+ var buffer = capture.getCapturedAudioBuffer();
+ IAudioSource mysound = audioMgr.createFromRaw("sound1", buffer.getReadBuffer(), buffer.getLength(), CAPTURE_FREQUENCY, CAPTURE_FORMAT);
+ buffer.Dispose();
if (mysound != null)
{
@@ -120,6 +118,7 @@ namespace CSharpTutorial4_AudioCapture
}
}
}
+
audioMgr.Dispose();
Console.WriteLine(@"Press any key to quit ");
diff --git a/Samples/CSharpAudioPlayer/bin/debug/EAXLegacyPreset_d.dll b/Samples/CSharpAudioPlayer/bin/debug/EAXLegacyPreset_d.dll
index bdbe066..39589b8 100644
Binary files a/Samples/CSharpAudioPlayer/bin/debug/EAXLegacyPreset_d.dll and b/Samples/CSharpAudioPlayer/bin/debug/EAXLegacyPreset_d.dll differ
diff --git a/Samples/CSharpAudioPlayer/bin/debug/cAp_mp3Decoder_d.dll b/Samples/CSharpAudioPlayer/bin/debug/cAp_mp3Decoder_d.dll
index e15a9a8..1b2bd01 100644
Binary files a/Samples/CSharpAudioPlayer/bin/debug/cAp_mp3Decoder_d.dll and b/Samples/CSharpAudioPlayer/bin/debug/cAp_mp3Decoder_d.dll differ
diff --git a/Samples/CSharpAudioPlayer/bin/debug/cAudioCSharpWrapper.dll b/Samples/CSharpAudioPlayer/bin/debug/cAudioCSharpWrapper.dll
index 5abb999..19ced3b 100644
Binary files a/Samples/CSharpAudioPlayer/bin/debug/cAudioCSharpWrapper.dll and b/Samples/CSharpAudioPlayer/bin/debug/cAudioCSharpWrapper.dll differ
diff --git a/Samples/CSharpAudioPlayer/bin/debug/cAudio_d.dll b/Samples/CSharpAudioPlayer/bin/debug/cAudio_d.dll
index 9fcde04..047901e 100644
Binary files a/Samples/CSharpAudioPlayer/bin/debug/cAudio_d.dll and b/Samples/CSharpAudioPlayer/bin/debug/cAudio_d.dll differ
diff --git a/Samples/CSharpAudioPlayer/bin/release/EAXLegacyPreset.dll b/Samples/CSharpAudioPlayer/bin/release/EAXLegacyPreset.dll
index 5d0fa31..bd56882 100644
Binary files a/Samples/CSharpAudioPlayer/bin/release/EAXLegacyPreset.dll and b/Samples/CSharpAudioPlayer/bin/release/EAXLegacyPreset.dll differ
diff --git a/Samples/CSharpAudioPlayer/bin/release/cAp_mp3Decoder.dll b/Samples/CSharpAudioPlayer/bin/release/cAp_mp3Decoder.dll
index 48fb1d1..04520cd 100644
Binary files a/Samples/CSharpAudioPlayer/bin/release/cAp_mp3Decoder.dll and b/Samples/CSharpAudioPlayer/bin/release/cAp_mp3Decoder.dll differ
diff --git a/Samples/CSharpAudioPlayer/bin/release/cAudio.dll b/Samples/CSharpAudioPlayer/bin/release/cAudio.dll
index e0fb4b8..404cddf 100644
Binary files a/Samples/CSharpAudioPlayer/bin/release/cAudio.dll and b/Samples/CSharpAudioPlayer/bin/release/cAudio.dll differ
diff --git a/Samples/CSharpAudioPlayer/bin/release/cAudioCSharpWrapper.dll b/Samples/CSharpAudioPlayer/bin/release/cAudioCSharpWrapper.dll
index 4ed2afb..7c3e68d 100644
Binary files a/Samples/CSharpAudioPlayer/bin/release/cAudioCSharpWrapper.dll and b/Samples/CSharpAudioPlayer/bin/release/cAudioCSharpWrapper.dll differ
diff --git a/Samples/Tutorial4_AudioCapture/src/main.cpp b/Samples/Tutorial4_AudioCapture/src/main.cpp
index dc279ff..ca19164 100644
--- a/Samples/Tutorial4_AudioCapture/src/main.cpp
+++ b/Samples/Tutorial4_AudioCapture/src/main.cpp
@@ -107,13 +107,14 @@ int main(int argc, char* argv[])
//Not completely necessary, as starting a capture again will clear the old audio data
currentsize = capture->getCurrentCapturedAudioSize();
- char* buffer = new char[currentsize];
- cout << "Captured " << capture->getCapturedAudio(buffer, currentsize) << " bytes of audio data. \n \n";
+ cout << "Captured " << currentsize << " bytes of audio data. \n \n";
+
+ cAudio::AudioCaptureBuffer* buff = capture->getCapturedAudioBuffer();
//Create a IAudio object and load a sound from a file
- cAudio::IAudioSource* mysound = manager->createFromRaw("sound1", buffer, currentsize, CAPTURE_FREQUENCY, CAPTURE_FORMAT);
+ cAudio::IAudioSource* mysound = manager->createFromRaw("sound1", buff->getReadBuffer(), buff->getLength(), CAPTURE_FREQUENCY, CAPTURE_FORMAT);
- delete buffer;
+ delete buff;
if(mysound)
{
diff --git a/cAudio/Headers/cAudioCapture.h b/cAudio/Headers/cAudioCapture.h
index 545bb8b..aaa6404 100644
--- a/cAudio/Headers/cAudioCapture.h
+++ b/cAudio/Headers/cAudioCapture.h
@@ -54,6 +54,7 @@ namespace cAudio
virtual bool beginCapture();
virtual void stopCapture();
virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize);
+ virtual AudioCaptureBuffer* getCapturedAudioBuffer();
virtual unsigned int getCurrentCapturedAudioSize();
void getAvailableDevices();
diff --git a/cAudio/include/IAudioCapture.h b/cAudio/include/IAudioCapture.h
index 153ba26..aae831a 100644
--- a/cAudio/include/IAudioCapture.h
+++ b/cAudio/include/IAudioCapture.h
@@ -10,6 +10,9 @@
namespace cAudio
{
+ // Is responsible to create/destroy a capture buffer
+ class AudioCaptureBuffer;
+
//! Interface for capturing operations in the cAudio Engine.
class IAudioCapture
{
@@ -90,6 +93,9 @@ namespace cAudio
*/
virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize) = 0;
+ //! this method is the same as getCapturedAudio but it returns an managed CaptureBuffer
+ virtual AudioCaptureBuffer* getCapturedAudioBuffer() = 0;
+
//! Returns the current size of the internal audio buffer in bytes.
virtual unsigned int getCurrentCapturedAudioSize() = 0;
@@ -102,4 +108,46 @@ namespace cAudio
//!Removes all event handlers attached to this manager.
virtual void unRegisterAllEventHandlers() = 0;
};
+
+ // Is responsible to create/destroy a capture buffer
+ class AudioCaptureBuffer
+ {
+ public:
+ AudioCaptureBuffer(size_t inlength)
+ {
+ length = inlength;
+ buffer = new char[length];
+ }
+
+ AudioCaptureBuffer(const AudioCaptureBuffer& p)
+ {
+ buffer = p.buffer;
+ length = p.length;
+ }
+
+ ~AudioCaptureBuffer()
+ {
+ delete buffer;
+ buffer = NULL;
+ }
+
+ const char* getReadBuffer() const
+ {
+ return buffer;
+ }
+
+ char* getWriteBuffer()
+ {
+ return buffer;
+ }
+
+ size_t getLength() const
+ {
+ return length;
+ }
+
+ private:
+ char* buffer;
+ size_t length;
+ };
};
\ No newline at end of file
diff --git a/cAudio/src/cAudioCapture.cpp b/cAudio/src/cAudioCapture.cpp
index 036fb02..e2fb864 100644
--- a/cAudio/src/cAudioCapture.cpp
+++ b/cAudio/src/cAudioCapture.cpp
@@ -147,6 +147,13 @@ namespace cAudio
Capturing = false;
}
+ AudioCaptureBuffer* cAudioCapture::getCapturedAudioBuffer()
+ {
+ AudioCaptureBuffer* buffer = new AudioCaptureBuffer(CaptureBuffer.size());
+ getCapturedAudio(buffer->getWriteBuffer(), buffer->getLength());
+ return buffer;
+ }
+
unsigned int cAudioCapture::getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize)
{
cAudioMutexBasicLock lock(Mutex);
diff --git a/cAudioCSharp/AudioCaptureBuffer.cs b/cAudioCSharp/AudioCaptureBuffer.cs
new file mode 100644
index 0000000..453bb1b
--- /dev/null
+++ b/cAudioCSharp/AudioCaptureBuffer.cs
@@ -0,0 +1,68 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.4
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace cAudio {
+
+using System;
+using System.Runtime.InteropServices;
+
+public class AudioCaptureBuffer : IDisposable {
+ private HandleRef swigCPtr;
+ protected bool swigCMemOwn;
+
+ internal AudioCaptureBuffer(IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = new HandleRef(this, cPtr);
+ }
+
+ internal static HandleRef getCPtr(AudioCaptureBuffer obj) {
+ return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+ }
+
+ ~AudioCaptureBuffer() {
+ Dispose();
+ }
+
+ public virtual void Dispose() {
+ lock(this) {
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ cAudioCSharpWrapperPINVOKE.delete_AudioCaptureBuffer(swigCPtr);
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
+ }
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ public AudioCaptureBuffer(uint inlength) : this(cAudioCSharpWrapperPINVOKE.new_AudioCaptureBuffer__SWIG_0(inlength), true) {
+ }
+
+ public AudioCaptureBuffer(AudioCaptureBuffer p) : this(cAudioCSharpWrapperPINVOKE.new_AudioCaptureBuffer__SWIG_1(AudioCaptureBuffer.getCPtr(p)), true) {
+ if (cAudioCSharpWrapperPINVOKE.SWIGPendingException.Pending) throw cAudioCSharpWrapperPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ public string getReadBuffer() {
+ string ret = cAudioCSharpWrapperPINVOKE.AudioCaptureBuffer_getReadBuffer(swigCPtr);
+ return ret;
+ }
+
+ public string getWriteBuffer() {
+ string ret = cAudioCSharpWrapperPINVOKE.AudioCaptureBuffer_getWriteBuffer(swigCPtr);
+ return ret;
+ }
+
+ public uint getLength() {
+ uint ret = cAudioCSharpWrapperPINVOKE.AudioCaptureBuffer_getLength(swigCPtr);
+ return ret;
+ }
+
+}
+
+}
diff --git a/cAudioCSharp/IAudioCapture.cs b/cAudioCSharp/IAudioCapture.cs
index a692d2b..5b10f5b 100644
--- a/cAudioCSharp/IAudioCapture.cs
+++ b/cAudioCSharp/IAudioCapture.cs
@@ -147,6 +147,12 @@ public class IAudioCapture : IDisposable {
return ret;
}
+ public virtual AudioCaptureBuffer getCapturedAudioBuffer() {
+ IntPtr cPtr = cAudioCSharpWrapperPINVOKE.IAudioCapture_getCapturedAudioBuffer(swigCPtr);
+ AudioCaptureBuffer ret = (cPtr == IntPtr.Zero) ? null : new AudioCaptureBuffer(cPtr, false);
+ return ret;
+ }
+
public virtual uint getCurrentCapturedAudioSize() {
uint ret = cAudioCSharpWrapperPINVOKE.IAudioCapture_getCurrentCapturedAudioSize(swigCPtr);
return ret;
diff --git a/cAudioCSharp/cAudioCSharp.csproj b/cAudioCSharp/cAudioCSharp.csproj
index eb0d58a..afc6f46 100644
--- a/cAudioCSharp/cAudioCSharp.csproj
+++ b/cAudioCSharp/cAudioCSharp.csproj
@@ -31,6 +31,7 @@
+
diff --git a/cAudioCSharp/cAudioCSharpWrapperPINVOKE.cs b/cAudioCSharp/cAudioCSharpWrapperPINVOKE.cs
index bc5540c..7576df4 100644
--- a/cAudioCSharp/cAudioCSharpWrapperPINVOKE.cs
+++ b/cAudioCSharp/cAudioCSharpWrapperPINVOKE.cs
@@ -669,6 +669,9 @@ class cAudioCSharpWrapperPINVOKE {
[DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_IAudioCapture_getCapturedAudio")]
public static extern uint IAudioCapture_getCapturedAudio(HandleRef jarg1, HandleRef jarg2, uint jarg3);
+ [DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_IAudioCapture_getCapturedAudioBuffer")]
+ public static extern IntPtr IAudioCapture_getCapturedAudioBuffer(HandleRef jarg1);
+
[DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_IAudioCapture_getCurrentCapturedAudioSize")]
public static extern uint IAudioCapture_getCurrentCapturedAudioSize(HandleRef jarg1);
@@ -681,6 +684,24 @@ class cAudioCSharpWrapperPINVOKE {
[DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_IAudioCapture_unRegisterAllEventHandlers")]
public static extern void IAudioCapture_unRegisterAllEventHandlers(HandleRef jarg1);
+ [DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_new_AudioCaptureBuffer__SWIG_0")]
+ public static extern IntPtr new_AudioCaptureBuffer__SWIG_0(uint jarg1);
+
+ [DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_new_AudioCaptureBuffer__SWIG_1")]
+ public static extern IntPtr new_AudioCaptureBuffer__SWIG_1(HandleRef jarg1);
+
+ [DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_delete_AudioCaptureBuffer")]
+ public static extern void delete_AudioCaptureBuffer(HandleRef jarg1);
+
+ [DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_AudioCaptureBuffer_getReadBuffer")]
+ public static extern string AudioCaptureBuffer_getReadBuffer(HandleRef jarg1);
+
+ [DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_AudioCaptureBuffer_getWriteBuffer")]
+ public static extern string AudioCaptureBuffer_getWriteBuffer(HandleRef jarg1);
+
+ [DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_AudioCaptureBuffer_getLength")]
+ public static extern uint AudioCaptureBuffer_getLength(HandleRef jarg1);
+
[DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_new_IAudioDecoder")]
public static extern IntPtr new_IAudioDecoder(HandleRef jarg1);
diff --git a/cAudioCSharpWrapper/src/cAudioWrapped_wrap.cxx b/cAudioCSharpWrapper/src/cAudioWrapped_wrap.cxx
index 9334661..e1293ef 100644
--- a/cAudioCSharpWrapper/src/cAudioWrapped_wrap.cxx
+++ b/cAudioCSharpWrapper/src/cAudioWrapped_wrap.cxx
@@ -3425,6 +3425,18 @@ SWIGEXPORT unsigned int SWIGSTDCALL CSharp_IAudioCapture_getCapturedAudio(void *
}
+SWIGEXPORT void * SWIGSTDCALL CSharp_IAudioCapture_getCapturedAudioBuffer(void * jarg1) {
+ void * jresult ;
+ cAudio::IAudioCapture *arg1 = (cAudio::IAudioCapture *) 0 ;
+ cAudio::AudioCaptureBuffer *result = 0 ;
+
+ arg1 = (cAudio::IAudioCapture *)jarg1;
+ result = (cAudio::AudioCaptureBuffer *)(arg1)->getCapturedAudioBuffer();
+ jresult = (void *)result;
+ return jresult;
+}
+
+
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_IAudioCapture_getCurrentCapturedAudioSize(void * jarg1) {
unsigned int jresult ;
cAudio::IAudioCapture *arg1 = (cAudio::IAudioCapture *) 0 ;
@@ -3465,6 +3477,78 @@ SWIGEXPORT void SWIGSTDCALL CSharp_IAudioCapture_unRegisterAllEventHandlers(void
}
+SWIGEXPORT void * SWIGSTDCALL CSharp_new_AudioCaptureBuffer__SWIG_0(unsigned long jarg1) {
+ void * jresult ;
+ size_t arg1 ;
+ cAudio::AudioCaptureBuffer *result = 0 ;
+
+ arg1 = (size_t)jarg1;
+ result = (cAudio::AudioCaptureBuffer *)new cAudio::AudioCaptureBuffer(arg1);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_new_AudioCaptureBuffer__SWIG_1(void * jarg1) {
+ void * jresult ;
+ cAudio::AudioCaptureBuffer *arg1 = 0 ;
+ cAudio::AudioCaptureBuffer *result = 0 ;
+
+ arg1 = (cAudio::AudioCaptureBuffer *)jarg1;
+ if (!arg1) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "cAudio::AudioCaptureBuffer const & type is null", 0);
+ return 0;
+ }
+ result = (cAudio::AudioCaptureBuffer *)new cAudio::AudioCaptureBuffer((cAudio::AudioCaptureBuffer const &)*arg1);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_delete_AudioCaptureBuffer(void * jarg1) {
+ cAudio::AudioCaptureBuffer *arg1 = (cAudio::AudioCaptureBuffer *) 0 ;
+
+ arg1 = (cAudio::AudioCaptureBuffer *)jarg1;
+ delete arg1;
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_AudioCaptureBuffer_getReadBuffer(void * jarg1) {
+ char * jresult ;
+ cAudio::AudioCaptureBuffer *arg1 = (cAudio::AudioCaptureBuffer *) 0 ;
+ char *result = 0 ;
+
+ arg1 = (cAudio::AudioCaptureBuffer *)jarg1;
+ result = (char *)((cAudio::AudioCaptureBuffer const *)arg1)->getReadBuffer();
+ jresult = SWIG_csharp_string_callback((const char *)result);
+ return jresult;
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_AudioCaptureBuffer_getWriteBuffer(void * jarg1) {
+ char * jresult ;
+ cAudio::AudioCaptureBuffer *arg1 = (cAudio::AudioCaptureBuffer *) 0 ;
+ char *result = 0 ;
+
+ arg1 = (cAudio::AudioCaptureBuffer *)jarg1;
+ result = (char *)(arg1)->getWriteBuffer();
+ jresult = SWIG_csharp_string_callback((const char *)result);
+ return jresult;
+}
+
+
+SWIGEXPORT unsigned long SWIGSTDCALL CSharp_AudioCaptureBuffer_getLength(void * jarg1) {
+ unsigned long jresult ;
+ cAudio::AudioCaptureBuffer *arg1 = (cAudio::AudioCaptureBuffer *) 0 ;
+ size_t result;
+
+ arg1 = (cAudio::AudioCaptureBuffer *)jarg1;
+ result = ((cAudio::AudioCaptureBuffer const *)arg1)->getLength();
+ jresult = (unsigned long)result;
+ return jresult;
+}
+
+
SWIGEXPORT void * SWIGSTDCALL CSharp_new_IAudioDecoder(void * jarg1) {
void * jresult ;
cAudio::IDataSource *arg1 = (cAudio::IDataSource *) 0 ;