openharmony 鸿蒙 capi-native-audio-suite-base-h

2026-08-25 浏览 (1)

native_audio_suite_base.h

Overview

The file declares the basic data structs used in audio creation.

File to include: <ohaudiosuite/native_audio_suite_base.h>

Library: libohaudiosuite.so

System capability: SystemCapability.Multimedia.Audio.SuiteEngine

Since: 22

Related module: OHAudioSuite

Summary

Structs

Nametypedef KeywordDescription
OH_AudioFormatOH_AudioFormatDescribes the audio stream information, which is used to describe the basic audio format, required for audio creation.
OH_AudioDataArrayOH_AudioDataArrayDescribes the input data for the multi-output rendering interface. It is used to obtain processed audio data when multiple output effect nodes are present in the pipeline.
OH_EqualizerFrequencyBandGainsOH_EqualizerFrequencyBandGainsDescribes the configuration parameters for the equalizer effect node used in audio creation.
OH_AudioSuite_SpaceRenderPositionParamsOH_AudioSuite_SpaceRenderPositionParamsDefines the configuration parameters of the 3D spatial rendering effect node in fixed placement mode. Left-handed coordinate system: Extend your left hand and form an "L" shape with your thumb and index finger.
The thumb points to the right, the index finger points upward, and the other fingers point forward.
This creates a 3D left-handed coordinate system. In this coordinate system, the thumb, index finger,
and other fingers represent the positive directions of the x-axis, y-axis, and z-axis, respectively.
OH_AudioSuite_SpaceRenderRotationParamsOH_AudioSuite_SpaceRenderRotationParamsDefines the configuration parameters of the spatial rendering effect node in rotation mode.
OH_AudioSuite_SpaceRenderExtensionParamsOH_AudioSuite_SpaceRenderExtensionParamsDefines the configuration parameters of the spatial rendering effect node in extension mode.
OH_AudioSuite_PureVoiceChangeOptionOH_AudioSuite_PureVoiceChangeOptionDefines the pure voice change options of audio creation.
OH_AudioSuiteEngineStructOH_AudioSuiteEngineDescribes the audio creation engine, which is used to manage audio creation pipelines.
OH_AudioSuitePipelineStructOH_AudioSuitePipelineDescribes the audio creation pipeline, which is used to manage audio creation nodes.
OH_AudioNodeStructOH_AudioNodeDescribes a node for audio creation, which is used to represent instances of audio creation nodes.
OH_AudioNodeBuilderStructOH_AudioNodeBuilderDescribes a builder for nodes used in audio creation. It allows you to create an OH_AudioNode object, define the data formats for input and output nodes, and configures the callback interface for input nodes.

Enums

Nametypedef KeywordDescription
OH_AudioNode_TypeOH_AudioNode_TypeEnumerates the types of audio creation nodes.
OH_AudioSuite_PipelineWorkModeOH_AudioSuite_PipelineWorkModeEnumerates the working modes of the audio creation pipeline.
OH_AudioSuite_PipelineStateOH_AudioSuite_PipelineStateEnumerates the operational states of the audio creation pipeline.
OH_AudioSuite_ResultOH_AudioSuite_ResultEnumerates the error codes for audio creation.
OH_Audio_SampleFormatOH_Audio_SampleFormatEnumerates the bit depth of audio streams in an audio creation node.
OH_Audio_EncodingTypeOH_Audio_EncodingTypeEnumerates the encoding types of audio streams.
OH_Audio_SampleRateOH_Audio_SampleRateEnumerates the sample rates of audio streams.
OH_SoundFieldTypeOH_SoundFieldTypeEnumerates the effect modes of sound field effect nodes used for audio creation.
OH_EnvironmentTypeOH_EnvironmentTypeEnumerates the types of environment effect nodes used for audio creation.
OH_VoiceBeautifierTypeOH_VoiceBeautifierTypeEnumerates the types of voice beautifier effect nodes used for audio creation.
OH_AudioSuite_SurroundDirectionOH_AudioSuite_SurroundDirectionDefines the surround direction of the spatial rendering effect node in rotation mode.
OH_AudioSuite_PureVoiceChangeGenderOptionOH_AudioSuite_PureVoiceChangeGenderOptionDefines the gender of the pure voice change effect node used for audio creation.
OH_AudioSuite_PureVoiceChangeTypeOH_AudioSuite_PureVoiceChangeTypeDefines the voice change type of the pure voice change effect node used for audio creation.
OH_AudioSuite_GeneralVoiceChangeTypeOH_AudioSuite_GeneralVoiceChangeTypeDefines the type of audio creation node for general voice change.

Macros

NameDescription
EQUALIZER_BAND_NUM (10)Number of equalizer bands, defined as 10.
Since: 22
OH_PURE_VOICE_DEFAULT_PITCH (0.0f)Uses the pitch recommended by the system. Used for OH_AudioSuite_PureVoiceChangeOption.
Since: 23

Variables

NameDescription
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_DEFAULTDefault equalizer band gain settings.
Band gains: {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}.
Since: 22
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_BALLADSBuilt-in ballad effect for the equalizer node.
Band gains: {3, 5, 2, -4, 1, 2, -3, 1, 4, 5}.
Since: 22
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_CHINESE_STYLEBuilt-in Chinese style effect for the equalizer node.
Band gains: {0, 0, 2, 0, 0, 4, 4, 2, 2, 5}.
Since: 22
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_CLASSICALBuilt-in classical effect for the equalizer node.
Band gains: {2, 3, 2, 1, 0, 0, -5, -5, -5, -6}.
Since: 22
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_DANCE_MUSICBuilt-in dance music effect for the equalizer node.
Band gains: {4, 3, 2, -3, 0, 0, 5, 4, 2, 0}.
Since: 22
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_JAZZBuilt-in jazz effect for the equalizer node.
Band gains: {2, 0, 2, 3, 6, 5, -1, 3, 4, 4}.
Since: 22
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_POPBuilt-in pop effect for the equalizer node.
Band gains: {5, 2, 1, -1, -5, -5, -2, 1, 2, 4}.
Since: 22
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_RBBuilt-in R&B effect for the equalizer node.
Band gains: {1, 4, 5, 3, -2, -2, 2, 3, 5, 5}.
Since: 22
const OH_EqualizerFrequencyBandGains OH_EQUALIZER_PARAM_ROCKBuilt-in rock effect for the equalizer node.
Band gains: {6, 4, 4, 2, 0, 1, 3, 3, 5, 4}.
Since: 22

Enum Description

OH_AudioNode_Type

enum OH_AudioNode_Type

Description

Enumerates the types of audio creation nodes.

Since: 22

ValueDescription
INPUT_NODE_TYPE_DEFAULT = 1Input node that supports obtaining audio data from applications.
OUTPUT_NODE_TYPE_DEFAULT = 101Output node that supports providing audio data to applications.
EFFECT_NODE_TYPE_EQUALIZER = 201Equalizer effect node. The output audio format of the equalizer effect node is as follows:
Sample rate: 48000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 2
EFFECT_NODE_TYPE_NOISE_REDUCTION = 202Noise reduction effect node. The output audio format of the noise reduction effect node is as follows:
Sample rate: 16000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 1
EFFECT_NODE_TYPE_SOUND_FIELD = 203Sound field effect node. The sound field effect node supports the sound field types enumerated in OH_SoundFieldType.
The output audio format of the sound field effect node is as follows:
Sample rate: 48000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 2
EFFECT_MULTII_OUTPUT_NODE_TYPE_AUDIO_SEPARATION = 204Source separation effect node. The source separation effect node can only be connected to an output node.
The output audio format of the source separation effect node is as follows:
Sample rate: 48000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_F32LE
Channel count: 4 (first 2 channels for vocals, last 2 for accompaniment)
EFFECT_NODE_TYPE_VOICE_BEAUTIFIER = 205Voice beautification effect node. The voice beautification effect node supports the voice beautification types enumerated in OH_VoiceBeautifierType.
The output audio format of the voice beautification effect node is as follows:
Sample rate: 48000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 2
EFFECT_NODE_TYPE_ENVIRONMENT_EFFECT = 206Environment effect node. The output audio format of the environment effect node is as follows:
Sample rate: 48000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 2
EFFECT_NODE_TYPE_AUDIO_MIXER = 207Audio mixer effect node. The output audio format of the audio mixer effect node is as follows:
Sample rate: OH_Audio_SampleRate
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_F32LE
Channel count: 2
EFFECT_NODE_TYPE_SPACE_RENDER = 208Spatial rendering effect node. The output audio format of the spatial rendering effect node is as follows:
Sample rate: 48000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 2
Since: 23
EFFECT_NODE_TYPE_PURE_VOICE_CHANGE = 209Pure voice change effect node. The output audio format of the pure voice change effect node is as follows:
Sample rate: 16000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 1
Since: 23
EFFECT_NODE_TYPE_GENERAL_VOICE_CHANGE = 210General voice change effect node. The output audio format of the general voice change effect node is as follows:
Sample rate: 48000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 2
Since: 23
EFFECT_NODE_TYPE_TEMPO_PITCH = 211Tempo and pitch effect node. The output audio format of the tempo and pitch effect node is as follows:
Sample rate: 48000 Hz
Sample format: OH_Audio_SampleFormat.AUDIO_SAMPLE_S16LE
Channel count: 1
Since: 23

OH_AudioSuite_PipelineWorkMode

enum OH_AudioSuite_PipelineWorkMode

Description

Enumerates the working modes of the audio creation pipeline.

Since: 22

ValueDescription
AUDIOSUITE_PIPELINE_EDIT_MODE = 1Edit mode. In this mode, the pipeline can create various effect nodes for audio processing.
AUDIOSUITE_PIPELINE_REALTIME_MODE = 2Real-time rendering mode. In this mode, processed audio is played in real time during audio processing.
Only equalizer effect processing is supported in this mode.

OH_AudioSuite_PipelineState

enum OH_AudioSuite_PipelineState

Description

Enumerates the operational states of the audio creation pipeline.

Since: 22

ValueDescription
AUDIOSUITE_PIPELINE_STOPPED = 1The pipeline is stopped.
AUDIOSUITE_PIPELINE_RUNNING = 2The pipeline is running.

OH_AudioSuite_Result

enum OH_AudioSuite_Result

Description

Enumerates the error codes for audio creation.

Since: 22

ValueDescription
AUDIOSUITE_SUCCESS = 0The call is successful.
AUDIOSUITE_ERROR_INVALID_PARAM = 1Invalid input parameters.
AUDIOSUITE_ERROR_INVALID_STATE = 2Invalid state.
AUDIOSUITE_ERROR_SYSTEM = 3General system error.
AUDIOSUITE_ERROR_UNSUPPORTED_FORMAT = 4Unsupported audio format, such as unsupported encoding type or sample format.
AUDIOSUITE_ERROR_ENGINE_NOT_EXIST = 5The engine does not exist.
AUDIOSUITE_ERROR_PIPELINE_NOT_EXIST = 6The pipeline does not exist.
AUDIOSUITE_ERROR_NODE_NOT_EXIST = 7The node does not exist.
AUDIOSUITE_ERROR_UNSUPPORTED_CONNECT = 8Nodes do not support connection.
AUDIOSUITE_ERROR_UNSUPPORTED_OPERATION = 9Unsupported operation. For example, the audio format cannot be set for effect nodes.
AUDIOSUITE_ERROR_CREATED_EXCEED_SYSTEM_LIMITS = 10The number of pipelines or nodes created reaches the upper limit. Specifically:
An engine supports the creation of up to 10 pipelines, with a maximum of 1 dedicated to real-time rendering.
Each pipeline can have up to 5 input nodes, 1 output node, 3 mixer nodes, 1 audio separation node, and up to 5 other effect nodes.
AUDIOSUITE_ERROR_REQUIRED_PARAMETERS_MISSING = 11Mandatory parameters are missing. For example, the callback function is not set for the input node, or the audio format is not set for the output node.
AUDIOSUITE_ERROR_TIMEOUT = 12Operation timed out.
AUDIOSUITE_ERROR_MEMORY_ALLOC_FAILED = 13Memory allocation failed.

OH_Audio_SampleFormat

enum OH_Audio_SampleFormat

Description

Enumerates the bit depth of audio streams in an audio creation node.

Since: 22

ValueDescription
AUDIO_SAMPLE_U8 = 0Unsigned 8-bit.
AUDIO_SAMPLE_S16LE = 1Short 16-bit little-endian.
AUDIO_SAMPLE_S24LE = 2Short 24-bit little-endian.
AUDIO_SAMPLE_S32LE = 3Short 32-bit little-endian.
AUDIO_SAMPLE_F32LE = 4Float 32-bit little-endian.

OH_Audio_EncodingType

enum OH_Audio_EncodingType

Description

Enumerates the encoding types of audio streams.

Since: 22

ValueDescription
AUDIO_ENCODING_TYPE_RAW = 0PCM encoding.

OH_Audio_SampleRate

enum OH_Audio_SampleRate

Description

Enumerates the sample rates of audio streams.

Since: 22

ValueDescription
SAMPLE_RATE_8000 = 8000Sample rate of 8 kHz.
SAMPLE_RATE_11025 = 11025Sample rate of 11.025 kHz.
SAMPLE_RATE_12000 = 12000Sample rate of 12 kHz.
SAMPLE_RATE_16000 = 16000Sample rate of 16 kHz.
SAMPLE_RATE_22050 = 22050Sample rate of 22.05 kHz.
SAMPLE_RATE_24000 = 24000Sample rate of 24 kHz.
SAMPLE_RATE_32000 = 32000Sample rate of 32 kHz.
SAMPLE_RATE_44100 = 44100Sample rate 44.1 kHz.
SAMPLE_RATE_48000 = 48000Sample rate of 48 kHz.
SAMPLE_RATE_64000 = 64000Sample rate of 64 kHz.
SAMPLE_RATE_88200 = 88200Sample rate of 88.2 kHz.
SAMPLE_RATE_96000 = 96000Sample rate of 96 kHz.
SAMPLE_RATE_176400 = 176400Sample rate of 176.4 kHz.
SAMPLE_RATE_192000 = 192000Sample rate of 192 kHz.

OH_SoundFieldType

enum OH_SoundFieldType

Description

Enumerates the effect modes of sound field effect nodes used for audio creation.

Since: 22

ValueDescription
SOUND_FIELD_FRONT_FACING = 1Front-facing sound field effect.
SOUND_FIELD_GRAND = 2Grand sound field effect.
SOUND_FIELD_NEAR = 3Near-listening sound field effect.
SOUND_FIELD_WIDE = 4Wide sound field effect.

OH_EnvironmentType

enum OH_EnvironmentType

Description

Enumerates the types of environment effect nodes used for audio creation.

Since: 22

ValueDescription
ENVIRONMENT_TYPE_BROADCAST = 1Broadcast environment effect.
ENVIRONMENT_TYPE_EARPIECE = 2Earpiece environment effect.
ENVIRONMENT_TYPE_UNDERWATER = 3Underwater environment effect.
ENVIRONMENT_TYPE_GRAMOPHONE = 4Gramophone environment effect.

OH_VoiceBeautifierType

enum OH_VoiceBeautifierType

Description

Enumerates the types of voice beautifier effect nodes used for audio creation.

Since: 22

ValueDescription
VOICE_BEAUTIFIER_TYPE_CLEAR = 1Clear voice beautifier effect.
VOICE_BEAUTIFIER_TYPE_THEATRE = 2Theatre voice beautifier effect.
VOICE_BEAUTIFIER_TYPE_CD = 3CD-quality voice beautifier effect.
VOICE_BEAUTIFIER_TYPE_RECORDING_STUDIO = 4Recording studio voice beautifier effect.

OH_AudioSuite_SurroundDirection

enum OH_AudioSuite_SurroundDirection

Description

Defines the surround direction of the spatial rendering effect node in rotation mode.

Since: 23

ValueDescription
SPACE_RENDER_CCW = 0Turn counterclockwise.
SPACE_RENDER_CW = 1Turn clockwise.

OH_AudioSuite_PureVoiceChangeGenderOption

enum OH_AudioSuite_PureVoiceChangeGenderOption

Description

Defines the gender of the voice change effect node used for audio creation.

Since: 23

ValueDescription
PURE_VOICE_CHANGE_FEMALE = 1Sets the voice to female.
PURE_VOICE_CHANGE_MALE = 2Sets the voice to male.

OH_AudioSuite_PureVoiceChangeType

enum OH_AudioSuite_PureVoiceChangeType

Description

Defines the voice change type of the pure voice change effect node used for audio creation.

Since: 23

ValueDescription
PURE_VOICE_CHANGE_TYPE_CARTOON = 1Sets the pure voice change type to cartoon.
PURE_VOICE_CHANGE_TYPE_CUTE = 2Sets the pure voice change type to cute.
PURE_VOICE_CHANGE_TYPE_FEMALE = 3Sets the pure voice change type to female.
PURE_VOICE_CHANGE_TYPE_MALE = 4Sets the pure voice change type to male.
PURE_VOICE_CHANGE_TYPE_MONSTER = 5Sets the pure voice change type to monster.
PURE_VOICE_CHANGE_TYPE_ROBOTS = 6Sets the pure voice change type to robot.
PURE_VOICE_CHANGE_TYPE_SEASONED = 7Sets the pure voice change type to seasoned.

OH_AudioSuite_GeneralVoiceChangeType

enum OH_AudioSuite_GeneralVoiceChangeType

Description

Defines the general voice change type for audio creation.

Since: 23

ValueDescription
GENERAL_VOICE_CHANGE_TYPE_CUTE = 1Sets the general voice change type to cute.
GENERAL_VOICE_CHANGE_TYPE_CYBERPUNK = 2Sets the general voice change type to cuberpunk.
GENERAL_VOICE_CHANGE_TYPE_FEMALE = 3Sets the general voice change type to female.
GENERAL_VOICE_CHANGE_TYPE_MALE = 4Sets the general voice change type to male.
GENERAL_VOICE_CHANGE_TYPE_MIX = 5Sets the general voice change type to mix.
GENERAL_VOICE_CHANGE_TYPE_MONSTER = 6Sets the general voice change type to monster.
GENERAL_VOICE_CHANGE_TYPE_SEASONED = 7Sets the general voice change type to seasoned.
GENERAL_VOICE_CHANGE_TYPE_SYNTH = 8Sets the general voice change type to synthesizer.
GENERAL_VOICE_CHANGE_TYPE_TRILL = 9Sets the general voice change type to trill.
GENERAL_VOICE_CHANGE_TYPE_WAR = 10Sets the general voice change type to war.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-native-audiostreambuilder-h

openharmony 鸿蒙 capi-ohaudiosuite

openharmony 鸿蒙 js-apis-inner-multimedia-systemSoundPlayer

openharmony 鸿蒙 arkts-apis-audio-i

openharmony 鸿蒙 capi-ohaudio

openharmony 鸿蒙 capi-ohmidi

openharmony 鸿蒙 arkts-apis-audio-AudioManager

openharmony 鸿蒙 capi-ohaudiosuite-oh-audiosuite-spacerenderpositionparams

openharmony 鸿蒙 capi-ohaudio-oh-audiostreaminfo

openharmony 鸿蒙 errorcode-ringtone

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/k1hurE6e