Simpleapo applies a simple gain factor to the audio data by multiplying it with the processed sample data. With the example in the DirectX SDK, I split the instances into separate instructions and separated the code.
struct simpleapoparams{ float gain;}; Class __declspec (uuid ("{5EB8D611-FF96-429D-8365-2DDF89A7C1CD}")) Csimpleapo:public Csamplexapobase<csimpleapo, Simpleapoparams>{public: Csimpleapo (); ~csimpleapo (); void doprocess (const simpleapoparams&, float32* __restrict pData, UINT32 cframes, UINT32 cchannels);};
Csimpleapo is derived from a template class Csamplexapobase, which is located in the file SampleAPOBase.h. The Xapo class and parameter classes are required when instantiating a template class: Apoclass and Parameterclass. A parameter class can be a struct body.
The template class implements the static instantiation function CreateInstance, as well as the lockforprocess and process interface functions. A pure virtual function doprocess is reserved to allow subclasses to implement different requirements.
The lockforprocess function simply gets the format:
memcpy (&M_WFX, Pinputlockedparameters[0].pformat, sizeof (WAVEFORMATEX));
The process function realizes that if the flag bit of the input buffer is xapo_buffer_silent, the buffer is set to 0. If xapo_buffer_valid, the data is valid, call Doprocess to gain the data:
parameterclass* Pparams; Pparams = (parameterclass*) beginprocess (); if (Pinputprocessparameters[0]. Bufferflags = = xapo_buffer_silent) {memset (pinputprocessparameters[0].pbuffer, 0, Pinputproces Sparameters[0]. Validframecount * m_wfx.nchannels * sizeof (FLOAT32)); Doprocess (*pparams, (float32* __restrict) Pinputprocessparameters[0].pbuffer, Pinputproce Ssparameters[0]. Validframecount, M_wfx.nchannels); } else if (Pinputprocessparameters[0]. Bufferflags = = xapo_buffer_valid) {doprocess (*pparams, (float32* __restrict) Pinputproce Ssparameters[0].pbuffer, Pinputprocessparameters[0]. Validframecount, M_wfx.nchannels); } endprocess ();
where the Beginprocess interface can get the latest parameters set through Seteffectparameters. Xapo can only call this method within the process function.
Endprocess tells Cxapoparametersbase,xapo that the latest parameters for receiving settings have been completed. This method must also be called within the process method.
AC qq:1245178753
This address: http://blog.csdn.net/u011417605/article/details/51201686
Sample code Download: http://download.csdn.net/detail/u011417605/9497124
XAudio2 Learning Simpleapo