using System; using System.Runtime.InteropServices; namespace SharpDX.XAudio2 { /// /// Functions /// /// static partial class XAudio28Functions { /// ///

Creates a new XAudio2 object and returns a reference to its interface.

///
/// No documentation. /// No documentation. /// No documentation. ///

Returns if successful, an error code otherwise. See XAudio2 Error Codes for descriptions of XAudio2 specific error codes.

/// ///

The DirectX SDK versions of XAUDIO2 supported a flag to select between the release and 'checked' version. This flag is not supported or defined in the Windows 8 version of XAUDIO2.

Note??No versions of the DirectX SDK contain the xaudio2.lib import library. DirectX SDK versions use COM to create a new XAudio2 object.

///
/// /// microsoft.directx_sdk.xaudio2.xaudio2create /// HRESULT XAudio2Create([Out, Fast] IXAudio2** ppXAudio2,[In] unsigned int Flags,[In] unsigned int XAudio2Processor) /// XAudio2Create public static void XAudio2Create(SharpDX.XAudio2.XAudio2 xAudio2Out, int flags, int xAudio2Processor) { unsafe { IntPtr xAudio2Out_ = IntPtr.Zero; SharpDX.Result __result__; __result__= XAudio2Create_(&xAudio2Out_, flags, xAudio2Processor); ((SharpDX.XAudio2.XAudio2)xAudio2Out).NativePointer = xAudio2Out_; __result__.CheckError(); } } [DllImport("xaudio2_8.dll", EntryPoint = "XAudio2Create", CallingConvention = CallingConvention.StdCall)] private unsafe static extern int XAudio2Create_(void* arg0,int arg1,int arg2); /// ///

Creates a new reverb audio processing object (APO), and returns a reference to it.

///
///

Contains a reference to the reverb APO that is created.

///

If this function succeeds, it returns . Otherwise, it returns an error code.

/// ///

XAudio2CreateReverb creates an effect performing Princeton Digital Reverb. The XAPO effect library (XAPOFX) includes an alternate reverb effect. Use CreateFX to create this alternate effect.

The reverb APO supports has the following restrictions:

  • Input audio data must be FLOAT32.
  • Framerate must be within XAUDIO2FX_REVERB_MIN_FRAMERATE (20,000 Hz) and XAUDIO2FX_REVERB_MAX_FRAMERATE (48,000 Hz).
  • The input and output channels must be one of the following combinations.
    • Mono input and mono output
    • Mono input and 5.1 output
    • Stereo input and stereo output
    • Stereo input and 5.1 output
The reverb APO maintains internal state information between processing samples. You can only use an instance of the APO with one source of audio data at a time. Multiple voices that require reverb effects would each need to create a separate reverb effect withXAudio2CreateReverb.

For information about creating new effects for use with XAudio2, see the XAPO Overview.

Windows

Because XAudio2CreateReverb calls CoCreateInstance on Windows, the application must have called the CoInitializeEx method before calling XAudio2CreateReverb. has the same requirement, which means CoInitializeEx typically will be called long before XAudio2CreateReverb is called.

A typical calling pattern on Windows would be as follows:

#ifndef _XBOX	
        /// CoInitializeEx(null, COINIT_MULTITHREADED);	
        /// #endif	
        /// * pXAudio2 = null;	
        ///  hr;	
        /// if ( FAILED(hr = ( &pXAudio2, 0,  ) ) ) return hr;	
        /// ...	
        ///  * pReverbAPO;	
        /// XAudio2CreateReverb(&pReverbAPO);	
        /// 

?

The xaudio2fx.h header defines the AudioReverb class as a cross-platform audio processing object (XAPO).

class __declspec(uuid("C2633B16-471B-4498-B8C5-4F0959E2EC09")) AudioReverb; ///

XAudio2CreateReverb returns this object as a reference to a reference to in the ppApo parameter. Although you can query the and interfaces from this , you typically never use these interfaces directly. Instead, you use them when you create a voice to add them as part of the effects chain.

The reverb uses the parameter structure that you access via the .

Note??XAudio2CreateReverb is an inline function in xaudio2fx.h that calls CreateAudioReverb:

XAUDIO2FX_STDAPI CreateAudioReverb(_Outptr_ ** ppApo); /// __inline XAudio2CreateReverb(_Outptr_ ** ppApo, UINT32 /*Flags*/ DEFAULT(0)) /// { return CreateAudioReverb(ppApo); /// } /// ///
/// /// microsoft.directx_sdk.xaudio2.xaudio2createreverb /// HRESULT CreateAudioReverb([Out, Fast] IUnknown** ppApo) /// CreateAudioReverb public static void CreateAudioReverb(SharpDX.ComObject apoOut) { unsafe { IntPtr apoOut_ = IntPtr.Zero; SharpDX.Result __result__; __result__= CreateAudioReverb_(&apoOut_); ((SharpDX.ComObject)apoOut).NativePointer = apoOut_; __result__.CheckError(); } } [DllImport("xaudio2_8.dll", EntryPoint = "CreateAudioReverb", CallingConvention = CallingConvention.StdCall)] private unsafe static extern int CreateAudioReverb_(void* arg0); /// ///

Creates a new volume meter audio processing object (APO) and returns a reference to it.

///
///

Contains the created volume meter APO.

///

If this function succeeds, it returns . Otherwise, it returns an error code.

/// ///

For information on creating new effects for use with XAudio2, see the XAPO Overview.

Windows

Because XAudio2CreateVolumeMeter calls CoCreateInstance on Windows, the application must have called the CoInitializeEx method before calling XAudio2CreateVolumeMeter. has the same requirement, which means CoInitializeEx typically will be called long before XAudio2CreateVolumeMeter is called.

A typical calling pattern on Windows would be as follows:

#ifndef _XBOX	
        /// CoInitializeEx(null, COINIT_MULTITHREADED);	
        /// #endif	
        /// * pXAudio2 = null;	
        ///  hr;	
        /// if ( FAILED(hr = ( &pXAudio2, 0,  ) ) ) return hr;	
        /// ...	
        ///  * pVolumeMeterAPO;	
        /// XAudio2CreateVolumeMeter(&pVolumeMeterAPO);	
        /// 

?

The xaudio2fx.h header defines the AudioVolumeMeter class as a cross-platform audio processing object (XAPO).

class __declspec(uuid("4FC3B166-972A-40CF-BC37-7DB03DB2FBA3")) AudioVolumeMeter; ///

XAudio2CreateVolumeMeter returns this object as a reference to a reference to in the ppApo parameter. Although you can query the and interfaces from this , you typically never use these interfaces directly. Instead, you use them when you create a voice to add them as part of the effects chain.

The volume meter uses the parameter structure that you access via the method when the XAPO is bound to the audio graph.

Note??XAudio2CreateVolumeMeter is an inline function in xaudio2fx.h that calls CreateAudioVolumeMeter:

XAUDIO2FX_STDAPI CreateAudioVolumeMeter(_Outptr_ ** ppApo); /// __inline XAudio2CreateVolumeMeter(_Outptr_ ** ppApo, UINT32 /*Flags*/ DEFAULT(0)) /// { return CreateAudioVolumeMeter(ppApo); /// } /// ///
/// /// microsoft.directx_sdk.xaudio2.xaudio2createvolumemeter /// HRESULT CreateAudioVolumeMeter([Out, Fast] IUnknown** ppApo) /// CreateAudioVolumeMeter public static void CreateAudioVolumeMeter(SharpDX.ComObject apoOut) { unsafe { IntPtr apoOut_ = IntPtr.Zero; SharpDX.Result __result__; __result__= CreateAudioVolumeMeter_(&apoOut_); ((SharpDX.ComObject)apoOut).NativePointer = apoOut_; __result__.CheckError(); } } [DllImport("xaudio2_8.dll", EntryPoint = "CreateAudioVolumeMeter", CallingConvention = CallingConvention.StdCall)] private unsafe static extern int CreateAudioVolumeMeter_(void* arg0); } }