Wrapping System-supplied sAPOs

Implementing your own sAPO

You can wrap a system-supplied sAPO by basing your custom class on the CBaseAudioProcessingObject base class, which is declared in the Baseaudioprocessingobject.h file. This approach involves introducing new functionality into the CBaseAudioProcessingObject base class to create a customized sAPO. The CBaseAudioProcessingObject base class implements much of the functionality that an sAPO requires. It provides default implementations for most of the methods in the three required interfaces. The primary exception is the IAudioProcessingObjectRT::APOProcess method.

By using CBaseAudioProcessingObject, you can more easily implement an sAPO. If an sAPO has no special format requirements and operates on the default float32 format, the default implementations of the interface methods that are included in CBaseAudioProcessingObject should be sufficient. Given the default implementations, only three main methods must be implemented: IAudioProcessingObject::IsInputFormatSupported, IAudioProcessingObjectRT::APOProcess, and ValidateAndCacheConnectionInfo.

To develop your sAPOs based on the CBaseAudioProcessingObject class, perform the following steps:

  1. Create a class that inherits from CBaseAudioProcessingObject.

    The following C++ code example shows the creation of a class that inherits from CBaseAudioProcessingObject. For an actual implementation of this concept, follow instructions in the Audio Processing Objects Driver Sample section to go to the Swap sample, and then refer to the Swapapo.h file.

    
    // Custom APO class - LFX
    Class MyCustomSAPOLFX: public CBaseAudioProcessingObject
    {
     public:
    //Code for class goes here
    ...
    };
    
    

    Note   Because the signal processing that is performed by an LFX sAPO is different from the signal processing that is performed by a GFX sAPO, you must create separate classes for your LFX and GFX sAPOs.

  2. Implement the following three methods:

The following C++ code example shows an implementation of the APOProcess method for the sample class that you created in step 1. For an actual implementation of this concept, follow instructions in the Audio Processing Objects Driver Sample section to go to the Swap sample, and then refer to the Swapapolfx.cpp file.


// Custom implementation of APOProcess method
STDMETHODIMP_ (Void) MyCustomSAPOLFX::APOProcess (...)
{
// Code for method goes here. This code is the algorithm that actually
// processes the digital audio signal.
...
}

The following code example shows an implementation of the ValidateAndCacheConnectionInfo method. For an actual implementation of this method, follow instructions in the Audio Processing Objects Driver Sample section to go to the Swap sample, and then refer to the Swapapogfx.cpp file.


// Custom implementation of the ValidateAndCacheConnectionInfo method.
HRESULT CSwapAPOGFX::ValidateAndCacheConnectionInfo( ... )
{
// Code for method goes here.
// The code should validate the input/output format pair.
...
}

Note  The remaining interfaces and methods that your class inherits from CBaseAudioProcessingObject are described in detail in the Audioenginebaseapo.idl file.

You must provide a user interface to configure the features that you added to the custom sAPO. For more information about this, see the Implementing a UI for Configuring sAPOs topic.

Audio Processing Objects Driver Sample

The Swap sample is the sample that was developed to illustrate some features of audio processing objects. To access this sample and browse the code files, perform the following steps:

1. Follow this link: Audio Processing Objects Driver Sample
2. Click the BROWSE CODE tab.
3. In the left navigation pane, expand the APO item.
4. Click the file that you would like to browse, to see its contents to the right of the navigation pane. For example, click Swapapogfx.cpp to browse its contents.

 

 

Send comments about this topic to Microsoft

표시:
© 2014 Microsoft