* Make it easier to playback AudioCaptureBuffer
This commit is contained in:
parent
a4d12b68c7
commit
a585385f46
|
@ -38,7 +38,7 @@
|
|||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace CSharpTutorial4_AudioCapture
|
|||
|
||||
//Create a IAudio object and load a sound from a file
|
||||
var buffer = capture.getCapturedAudioBuffer();
|
||||
IAudioSource mysound = audioMgr.createFromRaw("sound1", buffer.getReadBuffer(), buffer.getLength(), CAPTURE_FREQUENCY, CAPTURE_FORMAT);
|
||||
IAudioSource mysound = audioMgr.createFromAudioBuffer("sound1", buffer, CAPTURE_FREQUENCY, CAPTURE_FORMAT);
|
||||
buffer.Dispose();
|
||||
|
||||
if (mysound != null)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -51,6 +51,7 @@ namespace cAudio
|
|||
virtual IAudioSource* create(const char* name, const char* filename, bool stream = false);
|
||||
virtual IAudioSource* createFromMemory(const char* name, const char* data, size_t length, const char* extension);
|
||||
virtual IAudioSource* createFromRaw(const char* name, const char* data, size_t length, unsigned int frequency, AudioFormats format);
|
||||
virtual IAudioSource* createFromAudioBuffer(const char* name, AudioCaptureBuffer* pBiffer, unsigned int frequency, AudioFormats format);
|
||||
|
||||
virtual bool registerAudioDecoder(IAudioDecoderFactory* factory, const char* extension);
|
||||
virtual void unRegisterAudioDecoder(const char* extension);
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace cAudio
|
|||
{
|
||||
class IAudioSource;
|
||||
class IAudioDecoderFactory;
|
||||
class AudioCaptureBuffer;
|
||||
|
||||
//! Interface for the playback capabilities of cAudio.
|
||||
class IAudioManager
|
||||
|
@ -121,6 +122,17 @@ namespace cAudio
|
|||
*/
|
||||
virtual IAudioSource* createFromRaw(const char* name, const char* data, size_t length, unsigned int frequency, AudioFormats format) = 0;
|
||||
|
||||
|
||||
//! Creates an Audio Source from AudioCaptureBuffer in a memory buffer.
|
||||
/**
|
||||
\param name: Name of the audio source.
|
||||
\param AudioCaptureBuffer: Pointer to a AudioCaptureBuffer in memory to load the data from.
|
||||
\param frequency: Frequency (or sample rate) of the audio data.
|
||||
\param format: Format of the audio data.
|
||||
\return A pointer to an Audio Source or NULL if creation failed.
|
||||
*/
|
||||
virtual IAudioSource* createFromAudioBuffer(const char* name, AudioCaptureBuffer* pBiffer, unsigned int frequency, AudioFormats format) = 0;
|
||||
|
||||
//! Register an Audio Decoder.
|
||||
/**
|
||||
\param factory: Pointer to the factory instance to use.
|
||||
|
|
|
@ -324,6 +324,11 @@ namespace cAudio
|
|||
return NULL;
|
||||
}
|
||||
|
||||
IAudioSource* cAudioManager::createFromAudioBuffer(const char* name, AudioCaptureBuffer* pBiffer, unsigned int frequency, AudioFormats format)
|
||||
{
|
||||
return createFromRaw(name, pBiffer->getWriteBuffer(), pBiffer->getLength(), frequency, format);
|
||||
}
|
||||
|
||||
IAudioSource* cAudioManager::createFromRaw(const char* name, const char* data, size_t length, unsigned int frequency, AudioFormats format)
|
||||
{
|
||||
if(!Initialized) return NULL;
|
||||
|
|
|
@ -164,6 +164,12 @@ public class IAudioManager : IDisposable {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public virtual IAudioSource createFromAudioBuffer(string name, AudioCaptureBuffer pBiffer, uint frequency, AudioFormats format) {
|
||||
IntPtr cPtr = cAudioCSharpWrapperPINVOKE.IAudioManager_createFromAudioBuffer(swigCPtr, name, AudioCaptureBuffer.getCPtr(pBiffer), frequency, (int)format);
|
||||
IAudioSource ret = (cPtr == IntPtr.Zero) ? null : new IAudioSource(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public virtual bool registerAudioDecoder(IAudioDecoderFactory factory, string extension) {
|
||||
bool ret = cAudioCSharpWrapperPINVOKE.IAudioManager_registerAudioDecoder(swigCPtr, IAudioDecoderFactory.getCPtr(factory), extension);
|
||||
return ret;
|
||||
|
|
|
@ -837,6 +837,9 @@ class cAudioCSharpWrapperPINVOKE {
|
|||
[DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_IAudioManager_createFromRaw")]
|
||||
public static extern IntPtr IAudioManager_createFromRaw(HandleRef jarg1, string jarg2, string jarg3, uint jarg4, uint jarg5, int jarg6);
|
||||
|
||||
[DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_IAudioManager_createFromAudioBuffer")]
|
||||
public static extern IntPtr IAudioManager_createFromAudioBuffer(HandleRef jarg1, string jarg2, HandleRef jarg3, uint jarg4, int jarg5);
|
||||
|
||||
[DllImport("cAudioCSharpWrapper", EntryPoint="CSharp_IAudioManager_registerAudioDecoder")]
|
||||
public static extern bool IAudioManager_registerAudioDecoder(HandleRef jarg1, HandleRef jarg2, string jarg3);
|
||||
|
||||
|
|
|
@ -4153,6 +4153,26 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_IAudioManager_createFromRaw(void * jarg1, c
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_IAudioManager_createFromAudioBuffer(void * jarg1, char * jarg2, void * jarg3, unsigned int jarg4, int jarg5) {
|
||||
void * jresult ;
|
||||
cAudio::IAudioManager *arg1 = (cAudio::IAudioManager *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
cAudio::AudioCaptureBuffer *arg3 = (cAudio::AudioCaptureBuffer *) 0 ;
|
||||
unsigned int arg4 ;
|
||||
cAudio::AudioFormats arg5 ;
|
||||
cAudio::IAudioSource *result = 0 ;
|
||||
|
||||
arg1 = (cAudio::IAudioManager *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
arg3 = (cAudio::AudioCaptureBuffer *)jarg3;
|
||||
arg4 = (unsigned int)jarg4;
|
||||
arg5 = (cAudio::AudioFormats)jarg5;
|
||||
result = (cAudio::IAudioSource *)(arg1)->createFromAudioBuffer((char const *)arg2,arg3,arg4,arg5);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_IAudioManager_registerAudioDecoder(void * jarg1, void * jarg2, char * jarg3) {
|
||||
unsigned int jresult ;
|
||||
cAudio::IAudioManager *arg1 = (cAudio::IAudioManager *) 0 ;
|
||||
|
|
Loading…
Reference in New Issue