目录

Audio Creation Overview (C/C++)

Starting from API version 22, OHAudioSuite is provided for audio creation. OHAudioSuite is a professional audio effects processing interface designed to help you efficiently build audio creation applications. It offers high-quality, low-latency, intelligent audio processing capabilities, and integrates a variety of audio effects such as noise reduction, equalization, and vocal separation. You can easily integrate these features into your application based on specific use cases.

OHAudioSuite is built around three core concepts: engine, pipeline, and node.

Figure 1 Implementation principle of audio creation

Engine

The engine in OHAudioSuite is an object that centrally manages audio pipelines and controls offline editing (C/C++) and real-time preview (C/C++). You can build audio processing chains based on your requirements. The calling process is shown in the figure above: initiated by the app, the interfaces of OHAudioSuite are called to sequentially create an engine, pipelines, and nodes. The created nodes are then connected within a pipeline to transmit PCM (Pulse Code Modulation) audio data, enabling the corresponding effect nodes to perform audio effect processing. When a pipeline is stopped, you can connect, disconnect, and remove nodes with certain restrictions (for specific rules, see Pipeline Usage Rules), achieving complex audio effect processing by adjusting node orchestration.

An engine supports the creation of up to 10 pipelines. Before API version 26.0.0, at most one pipeline could be dedicated to real-time preview. Starting from API version 26.0.0, the number of real-time preview pipelines is no longer separately restricted, but the total number of pipelines must still not exceed 10.

Node

[h2]Introduction to Nodes

A node is the minimum unit of audio rendering. It provides the corresponding audio effect processing capability based on its functionality. Nodes themselves cannot be called independently; they must be attached to pipelines and engines for use.

OHAudioSuite supports three types of nodes: input node, output node, and effect node.

Node Type Description
input node Supports input of PCM audio data in various formats.
effect node

Provides audio effect processing.

For details about the currently supported effect nodes, see Audio Effects (C/C++).

output node Supports setting the PCM format of the output audio.

For details about the complete node types, see OH_AudioNode_Type.

[h2]Functionalities of Nodes

Pipeline

A pipeline is an object that centrally manages the connection and configuration of audio nodes. It supports two working modes: offline editing (C/C++) and real-time preview (C/C++).

The pipeline data processing uses a reverse drive mechanism. Initiated by OH_AudioSuiteEngine_RenderFrame() or OH_AudioSuiteEngine_MultiRenderFrame(), the output node requests data from the upstream connected nodes level by level, ultimately prompting the input node's OH_InputNode_RequestDataCallback() callback function to request the audio data to be processed from the developer.

Figure 2 Pipeline running state

The table below describes these states.

State Description
stopped

Initial state, or entered from the working state via the OH_AudioSuiteEngine_StopPipeline() command.

After switching to the stopped state, each node releases its buffers.

running

Working state, or entered from the initial state via the OH_AudioSuiteEngine_StartPipeline() command.

This function performs a pipeline integrity check, including whether there are valid connections and whether any node has connection errors.

[h2]Functionalities of Pipelines

[h2]Pipeline Usage Rules

A pipeline is composed of nodes. The rules for creating nodes in a pipeline are as follows.

The rules for orchestrating nodes in a pipeline are as follows:

Complete Sample Code