ISVP-SDK  3.12.0
Ingenic Smart Video Platform SDK
Data Structures | Macros | Enumerations | Enumerator | Functions | Variables

audio module, including audio record and playback, audio encoding and decoding, volume and gain setting, (audio) echo cancellation, automatic gain function and so on More...

Collaboration diagram for IMP_Audio:

Data Structures

struct  IMPAudioIOAttr
 Audio input and output device attribute. More...
 
struct  IMPAudioFrame
 Audio frame structure. More...
 
struct  IMPAudioIChnParam
 Audio channel parameter structure. More...
 
struct  IMPAudioOChnState
 Data cache state structure of audio output channel. More...
 
struct  IMPAudioStream
 Define audio stream structure. More...
 
struct  IMPAudioEncChnAttr
 Define audio encoding channel attribute structure. More...
 
struct  IMPAudioEncEncoder
 Define the encoder attribute structure. More...
 
struct  IMPAudioDecChnAttr
 Define the decoded channel attribute structure. More...
 
struct  IMPAudioDecDecoder
 Define decoder attribute structure. More...
 
struct  IMPAudioAgcConfig
 Define AGC gain structure. More...
 

Macros

#define MAX_AUDIO_FRAME_NUM   50
 Maximum number of audio frames.
 

Enumerations

enum  IMPBlock { BLOCK = 0, NOBLOCK = 1 }
 Audio stream blocking type. More...
 
enum  IMPAudioSampleRate {
  AUDIO_SAMPLE_RATE_8000 = 8000, AUDIO_SAMPLE_RATE_16000 = 16000, AUDIO_SAMPLE_RATE_24000 = 24000, AUDIO_SAMPLE_RATE_44100 = 44100,
  AUDIO_SAMPLE_RATE_48000 = 48000, AUDIO_SAMPLE_RATE_96000 = 96000
}
 Audio sampling rate definition. More...
 
enum  IMPAudioBitWidth { AUDIO_BIT_WIDTH_16 = 16 }
 Audio sampling precision definition. More...
 
enum  IMPAudioSoundMode { AUDIO_SOUND_MODE_MONO = 1, AUDIO_SOUND_MODE_STEREO = 2 }
 Audio channel mode definition. More...
 
enum  IMPAudioPalyloadType {
  PT_PCM = 0, PT_G711A = 1, PT_G711U = 2, PT_G726 = 3,
  PT_AEC = 4, PT_ADPCM = 5, PT_MAX = 6
}
 Define audio payload type enumeration.
 
enum  IMPAudioDecMode { ADEC_MODE_PACK = 0, ADEC_MODE_STREAM = 1 }
 Define the decoding method. More...
 
enum  Level_ns { NS_LOW, NS_MODERATE, NS_HIGH, NS_VERYHIGH }
 Defines level of noise suppression. More...
 

Functions

int IMP_AI_SetPubAttr (int audioDevId, IMPAudioIOAttr *attr)
 Set audio input device attribute. More...
 
int IMP_AI_GetPubAttr (int audioDevId, IMPAudioIOAttr *attr)
 Get the attribute of the audio input device. More...
 
int IMP_AI_Enable (int audioDevId)
 Enable audio input device. More...
 
int IMP_AI_Disable (int audioDevId)
 Disable audio input device. More...
 
int IMP_AI_EnableChn (int audioDevId, int aiChn)
 Enable audio input channel. More...
 
int IMP_AI_DisableChn (int audioDevId, int aiChn)
 Disable audio input channel. More...
 
int IMP_AI_PollingFrame (int audioDevId, int aiChn, unsigned int timeout_ms)
 Polling audio stream cache. More...
 
int IMP_AI_GetFrame (int audioDevId, int aiChn, IMPAudioFrame *frm, IMPBlock block)
 Get audio frame. More...
 
int IMP_AI_ReleaseFrame (int audioDevId, int aiChn, IMPAudioFrame *frm)
 Release audio frame. More...
 
int IMP_AI_SetChnParam (int audioDevId, int aiChn, IMPAudioIChnParam *chnParam)
 Set audio input channel parameters. More...
 
int IMP_AI_GetChnParam (int audioDevId, int aiChn, IMPAudioIChnParam *chnParam)
 Set audio input channel parameters. More...
 
int IMP_AI_EnableAec (int aiDevId, int aiChn, int aoDevId, int aoChn)
 Enable audio echo cancellation feature of the specified audio input and audio output. More...
 
int IMP_AI_DisableAec (int aiDevId, int aiChn)
 Disable audio echo cancellation feature. More...
 
int IMP_AI_EnableNs (IMPAudioIOAttr *attr, int mode)
 Enable specified audio input noise suppression. More...
 
int IMP_AI_DisableNs (void)
 Disable noise suppression. More...
 
int IMP_AI_EnableAgc (IMPAudioIOAttr *attr, IMPAudioAgcConfig agcConfig)
 Enable automatic gain of audio input. More...
 
int IMP_AI_DisableAgc (void)
 Disable AI automatic gain feature. More...
 
int IMP_AO_EnableAgc (IMPAudioIOAttr *attr, IMPAudioAgcConfig agcConfig)
 Enable audio output automatic gain feature. More...
 
int IMP_AO_DisableAgc (void)
 Disable AO automatic gain feature. More...
 
int IMP_AI_EnableHpf (IMPAudioIOAttr *attr)
 Enable audio input for high pass filtering. More...
 
int IMP_AI_DisableHpf (void)
 Disable AI high pass filtering function. More...
 
int IMP_AO_EnableHpf (IMPAudioIOAttr *attr)
 Enable audio output for high pass filtering. More...
 
int IMP_AO_DisableHpf (void)
 Disable AO high pass filtering function. More...
 
int IMP_AO_SetPubAttr (int audioDevId, IMPAudioIOAttr *attr)
 Set audio input and output device attribute. More...
 
int IMP_AO_GetPubAttr (int audioDevId, IMPAudioIOAttr *attr)
 Get audio input and output device attribute. More...
 
int IMP_AO_Enable (int audioDevId)
 Enable audio output device. More...
 
int IMP_AO_Disable (int audioDevId)
 Disable audio output device. More...
 
int IMP_AO_EnableChn (int audioDevId, int aoChn)
 Enable audio output channel. More...
 
int IMP_AO_DisableChn (int audioDevId, int aoChn)
 Disable audio output channel. More...
 
int IMP_AO_SendFrame (int audioDevId, int aoChn, IMPAudioFrame *data, IMPBlock block)
 Send audio output frame. More...
 
int IMP_AO_PauseChn (int audioDevId, int aoChn)
 Pause audio output channel. More...
 
int IMP_AO_ResumeChn (int audioDevId, int aoChn)
 Resume audio output channel. More...
 
int IMP_AO_ClearChnBuf (int audioDevId, int aoChn)
 Clear the current audio data cache in the audio output channel. More...
 
int IMP_AO_QueryChnStat (int audioDevId, int aoChn, IMPAudioOChnState *status)
 Query the current audio data cache status in the audio output channel. More...
 
int IMP_AENC_CreateChn (int aeChn, IMPAudioEncChnAttr *attr)
 Create audio encode channel. More...
 
int IMP_AENC_DestroyChn (int aeChn)
 Destory audio encode channel. More...
 
int IMP_AENC_SendFrame (int aeChn, IMPAudioFrame *frm)
 Send audio encoding audio frame. More...
 
int IMP_AENC_PollingStream (int AeChn, unsigned int timeout_ms)
 Polling encoded audio stream cache. More...
 
int IMP_AENC_GetStream (int aeChn, IMPAudioStream *stream, IMPBlock block)
 Get the encoded stream. More...
 
int IMP_AENC_ReleaseStream (int aeChn, IMPAudioStream *stream)
 Releases the stream from the audio encoding channel. More...
 
int IMP_AENC_RegisterEncoder (int *handle, IMPAudioEncEncoder *encoder)
 Register encoder. More...
 
int IMP_AENC_ReleaseEncoder (int *handle)
 Release encoder. More...
 
int IMP_ADEC_CreateChn (int adChn, IMPAudioDecChnAttr *attr)
 Create audio decode channel. More...
 
int IMP_ADEC_DestroyChn (int adChn)
 Destory audio decoding channel. More...
 
int IMP_ADEC_SendStream (int adChn, IMPAudioStream *stream, IMPBlock block)
 Send audio stream to audio decoding channel. More...
 
int IMP_ADEC_PollingStream (int AdChn, unsigned int timeout_ms)
 Polling decode audio stream cache. More...
 
int IMP_ADEC_GetStream (int adChn, IMPAudioStream *stream, IMPBlock block)
 Get the decoded stream. More...
 
int IMP_ADEC_ReleaseStream (int adChn, IMPAudioStream *stream)
 Release of the stream from the audio decoding channel. More...
 
int IMP_ADEC_ClearChnBuf (int adChn)
 Clears the current audio data cache in the audio decode channel. More...
 
int IMP_ADEC_RegisterDecoder (int *handle, IMPAudioDecDecoder *decoder)
 Register decoder. More...
 
int IMP_ADEC_ReleaseDecoder (int *handle)
 Unregister Decoder. More...
 
int IMP_AI_SetVol (int audioDevId, int aiChn, int aiVol)
 ACODEC configuration. More...
 
int IMP_AI_GetVol (int audioDevId, int aiChn, int *vol)
 Get the volume of the audio input. More...
 
int IMP_AI_SetVolMute (int audioDevId, int aiChn, int mute)
 Set audio input mute. More...
 
int IMP_AO_SetVol (int audioDevId, int aoChn, int aoVol)
 Set audio output channel volume. More...
 
int IMP_AO_GetVol (int audioDevId, int aoChn, int *vol)
 Get audio output channel volume. More...
 
int IMP_AO_SetVolMute (int audioDevId, int aoChn, int mute)
 Set audio output mute. More...
 
int IMP_AI_SetGain (int audioDevId, int aiChn, int aiGain)
 Set audio input gain. More...
 
int IMP_AI_GetGain (int audioDevId, int aiChn, int *aiGain)
 Get AI gain value. More...
 
int IMP_AO_SetGain (int audioDevId, int aoChn, int aoGain)
 Set audio output gain. More...
 
int IMP_AO_GetGain (int audioDevId, int aoChn, int *aoGain)
 Get audio output gain. More...
 
int IMP_AO_Soft_Mute (int audioDevId, int aoChn)
 Output soft mute control. More...
 
int IMP_AO_Soft_UNMute (int audioDevId, int aoChn)
 Output soft unmute control. More...
 
int IMP_AI_GetFrameAndRef (int audioDevId, int aiChn, IMPAudioFrame *frm, IMPAudioFrame *ref, IMPBlock block)
 Get audio frame and output reference frame. More...
 
int IMP_AI_EnableAecRefFrame (int audioDevId, int aiChn, int audioAoDevId, int aoChn)
 Open access reference frame. More...
 
int IMP_AI_DisableAecRefFrame (int audioDevId, int aiChn, int audioAoDevId, int aoChn)
 Close access to the reference frame. More...
 
int IMP_AO_CacheSwitch (int audioDevId, int aoChn, int cache_en)
 close audio play cache More...
 
int IMP_AO_FlushChnBuf (int audioDevId, int aoChn)
 

Variables

IMPAudioSampleRate samplerate
 Audio sampling rate.
 
IMPAudioBitWidth bitwidth
 Audio sampling precision.
 
IMPAudioSoundMode soundmode
 Audio channel mode.
 
int frmNum
 Number of cached frames, range: [2, MAX_AUDIO_FRAME_NUM].
 
int numPerFrm
 Number of sample points per frame.
 
int chnCnt
 Number of channels supported.
 
IMPAudioBitWidth bitwidth
 Audio sampling precision.
 
IMPAudioSoundMode soundmode
 Audio channel mode.
 
uint32_t * virAddr
 Audio frame data virtual address.
 
uint32_t phyAddr
 Audio frame data physical address.
 
int64_t timeStamp
 Audio frame data time stamp.
 
int seq
 Audio frame data serial number.
 
int len
 Audio frame data length.
 
int usrFrmDepth
 Audio frame buffer depth.
 
int Rev
 retain
 
int chnTotalNum
 The total number of cached output channel.
 
int chnFreeNum
 Free cache blocks.
 
int chnBusyNum
 The number of cache be used.
 
uint8_t * stream
 Data stream pointer.
 
uint32_t phyAddr
 Data stream physical address.
 
int len
 Audio stream length.
 
int64_t timeStamp
 time stamp
 
int seq
 Audio stream serial number.
 
IMPAudioPalyloadType type
 Audio payload data type.
 
int bufSize
 buf size, in order to frame the unit, [2 ~ MAX_AUDIO_FRAME_NUM]
 
uint32_t * value
 Protocol attribute pointer.
 
IMPAudioPalyloadType type
 Encoding protocol type.
 
int maxFrmLen
 Maximum code stream length.
 
char name [16]
 encoder name
 
int(* openEncoder )(void *encoderAttr, void *encoder)
 
int(* encoderFrm )(void *encoder, IMPAudioFrame *data, unsigned char *outbuf, int *outLen)
 
int(* closeEncoder )(void *encoder)
 
IMPAudioPalyloadType type
 Audio decoding protocol type.
 
int bufSize
 Audio decoder cache size.
 
IMPAudioDecMode mode
 Decoding mode.
 
void * value
 Specific protocol attribute pointer.
 
IMPAudioPalyloadType type
 Audio decoding protocol type.
 
char name [16]
 Audio encoder name.
 
int(* openDecoder )(void *decoderAttr, void *decoder)
 
int(* decodeFrm )(void *decoder, unsigned char *inbuf, int inLen, unsigned short *outbuf, int *outLen, int *chns)
 
int(* getFrmInfo )(void *decoder, void *info)
 
int(* closeDecoder )(void *decoder)
 
int TargetLevelDbfs
 Gain level, the value of [0, 31], this refers to the target volume level, the unit is dB, is negative value. More...
 
int CompressionGaindB
 Set the maximum gain value, [0, 90], 0 represents no gain, the greater the value, the higher the gain. More...
 

Detailed Description

audio module, including audio record and playback, audio encoding and decoding, volume and gain setting, (audio) echo cancellation, automatic gain function and so on

1 overview

Audio function includes 5 modules: audio input, audio output, audio echo cancellation, audio encoding and audio decoding.
The existence of the audio input and audio output is the concept of the equipment and the channel, we all know that a MIC is a Device, and also can have multiple Channel input.
Similarly a SPK is a playback Device, and can also have multiple Channel output.
One Device supports only one Channel in this current version of the audio API.
Audio echo cancellation is located in the audio input interface, explicit explanation is embodied in the functional description.
Audio encoding, the current audio API can support such format audio coding: PT_G711A, PT_G711U and PT_G726 , when it comes to add a new encoding method, it is a must to register the encoder.
Audio decoding, the current audio API can support such format audio coding: PT_G711A, PT_G711U and PT_G726 , when it comes to add a new decoding method, it is a must to register the decoder.

2

The following is a detailed description of each module

2.1 Audio input

Audio input Device ID correspondence, 0: corresponding digital MIC; 1: corresponding simulation MIC
Audio input Channel, the current API only supports single channel.
Set the audio input volume, volume range: [-30 ~ 120]. - 30 represents mute, 120 represents the amplification of sound to 30dB, step 0.5dB. 60 means that the volume is set to a critical point,
in that case ,software does not increase or decrease the volume, when the volume value is less than 60, for each drop of 1, the volume is reduced by 0.5dB; when the volume value is greater than 60, for each rise of 1 the volume is increased by 0.5dB.

2.2 Audio output

Audio output Device ID correspondence, 0: corresponding to the default SPK; 1: MIC corresponding to other SPK
Audio output Channel,the current API only supports single channel.
Set the audio output volume, volume range: [-30 ~ 120]. - 30 represents mute, 120 represents the amplification of sound to 30dB, step 0.5dB. 60 means that the volume is set to a critical point,
in that case ,software does not increase or decrease the volume, when the volume value is less than 60, for each drop of 1, the volume is reduced by 0.5dB; when the volume value is greater than 60, for each rise of 1 the volume is increased by 0.5dB.

2.3 Audio echo cancellation(AEC)

Audio echo cancellation function belongs to the audio input interface, so to enable echo cancellation, you must first enable audio input device and channel.
Audio echo cancellation currently supports audio sampling rate of 8K and 16K. A frame data sample number is the multiple of 10ms audio data (e.g., 8K sampling rate, the data fed into: 8000 x 2 / 100 = 160byte integer multiple).
Audio echo cancellation for different devices and different packages will have different sound effects.
Adaptive support is not available in Audio Echo Cancellation (the AEC is not automatically configured), so for different devices there will be different echo cancellation parameters,
The parameter file of the Audio echo cancellation is located in the /etc/webrtc_profile.ini configuration file.
The profile format is as follows (Main need to debug the three parameters):
[Set_Far_Frame]
Frame_V=0.3
[Set_Near_Frame]
Frame_V=0.1
delay_ms=150
[Set_Far_Frame] represents the remote(far-end) parameter, the SPK represents the playback data parameters.
Fram_V represents audio amplitude scaling, the playback data can be adjusted by adjusting these parameters (this is used only for echo cancellation).
[Set_Near_Frame] represents the proximal(near-end) parameter, the MIC represents record data parameters.
Fram_V represents the audio amplitude ratio, the adjustment of these parameters can adjust the amplitude of the recording data (this is only used for echo cancellation).
Delay_ms, because of the delay between software and hardware, and the position between the SPK and MIC(they are placed at a certain distance), the SPK playback data will be processed by the MIC again. So, there will be some delay because the SPK data will have some impact on the MIC data.
This time represents the time difference of the playback data in data recording. (delay to assure that there won't be any echo at all).

2.4 Audio encoding

The current audio API supports PT_G711A, PT_G711U and PT_G726 format audio coding, if you need to add a new encoding method, you need to call the IMP_AENC_RegisterEncoder interface to register the encoder.

2.5 Audio decoding

The current audio API supports PT_G711A, PT_G711U and PT_G726 format audio decoding, if you need to add a new decoding method, you need to call the IMP_ADEC_RegisterDecoder interface to register the decoder.

Enumeration Type Documentation

Audio sampling precision definition.

Enumerator
AUDIO_BIT_WIDTH_16 

16bit sampling precision

Define the decoding method.

Enumerator
ADEC_MODE_PACK 

Pack decoding.

ADEC_MODE_STREAM 

Stream decoding.

Audio sampling rate definition.

Enumerator
AUDIO_SAMPLE_RATE_8000 

8KHz sampling rate

AUDIO_SAMPLE_RATE_16000 

16KHz sampling rate

AUDIO_SAMPLE_RATE_24000 

24KHz sampling rate

AUDIO_SAMPLE_RATE_44100 

44.1KHz sampling rate

AUDIO_SAMPLE_RATE_48000 

48KHz sampling rate

AUDIO_SAMPLE_RATE_96000 

96KHz sampling rate

Audio channel mode definition.

Enumerator
AUDIO_SOUND_MODE_MONO 

Single channel.

AUDIO_SOUND_MODE_STEREO 

Double channel.

enum IMPBlock

Audio stream blocking type.

Enumerator
BLOCK 

block

NOBLOCK 

not block

enum Level_ns

Defines level of noise suppression.

Enumerator
NS_LOW 

Low level noise suppression.

NS_MODERATE 

Medium level noise suppression.

NS_HIGH 

High level noise suppression.

NS_VERYHIGH 

Maximum level noise suppression.

Function Documentation

int IMP_ADEC_ClearChnBuf ( int  adChn)

Clears the current audio data cache in the audio decode channel.

Parameters
[in]adChnchannel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_ADEC_CreateChn ( int  adChn,
IMPAudioDecChnAttr attr 
)

Create audio decode channel.

Parameters
[in]adChnchannel number
[in]attrChannel attribute pointer.
Return values
0success.
non-0failure.
Remarks
sample code
1 int adChn = 0;
2 IMPAudioDecChnAttr attr;
3 attr.type = PT_G711A;
4 attr.bufSize = 20;
5 attr.mode = ADEC_MODE_PACK;
6 ret = IMP_ADEC_CreateChn(adChn, &attr);
7 if(ret != 0) {
8  IMP_LOG_ERR(TAG, "imp audio decoder create channel failed\n");
9  return ret;
10 }
Attention
no.
int IMP_ADEC_DestroyChn ( int  adChn)

Destory audio decoding channel.

Parameters
[in]adChnchannel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_ADEC_GetStream ( int  adChn,
IMPAudioStream stream,
IMPBlock  block 
)

Get the decoded stream.

Parameters
[in]adChnchannel number
[in]streamGet decoded stream
[in]blockBlocking / non blocking identifier.
Return values
0success.
non-0failure.
Remarks
See the IMP_ADEC_SendFrame function description for further instructions.
Attention
no.
int IMP_ADEC_PollingStream ( int  AdChn,
unsigned int  timeout_ms 
)

Polling decode audio stream cache.

Parameters
[in]AdChnaudio decode input channel number
[in]timeout_mspolling timeout time
Return values
0success.
non-0failure.
Remarks
no.
Attention
The current interface is used before using IMP_ADEC_GetStream. After calling successfully the current interface, we will have the audio encoding data ready then you can use the IMP_ADEC_GetStream to get the encoded data.
int IMP_ADEC_RegisterDecoder ( int *  handle,
IMPAudioDecDecoder decoder 
)

Register decoder.

Parameters
[in]ps32handleregister handle
[in]decoderDecoder attributes structure.
Return values
0success.
non-0failure.
Remarks
sample code
1 int handle_g711a = 0;
2 IMPAudioDecDecoder my_decoder;
3 sprintf(my_decoder.name, "%s", "MY_G711A");
4 my_decoder.openDecoder = NULL; // Decoder callback function
5 my_decoder.decodeFrm = MY_G711A_Decode_Frm; // Decoder callback function
6 my_decoder.getFrmInfo = NULL; // Decoder callback function
7 my_decoder.closeDecoder = NULL; // Decoder callback function
8 
9 // Register decoder
10 ret = IMP_ADEC_RegisterDecoder(&handle_g711a, &my_decoder);
11 if(ret != 0) {
12  IMP_LOG_ERR(TAG, "IMP_ADEC_RegisterDecoder failed\n");
13  return ret;
14 }
15 
16 // use decoder
17 int adChn = 0;
18 IMPAudioDecChnAttr attr;
19 attr.type = handle_g711a; // The encoder type is equal to the value of the handle_g711a returned by the successfully registered.
20 attr.bufSize = 20;
21 attr.mode = ADEC_MODE_PACK;
22 // create decode channel
23 ret = IMP_ADEC_CreateChn(adChn, &attr);
24 if(ret != 0) {
25  IMP_LOG_ERR(TAG, "imp audio decoder create channel failed\n");
26  return ret;
27 }
Attention
After registration, the use of the method as well as the use of SDK comes with an decoder.
After registration, the use of the method and the use of SDK in the decoder are all the same. (After registration, clients' methods and SDK prebuilt functions are considered as the SDK functions, that means the clients can change the content of the SDK as they wish)
int IMP_ADEC_ReleaseDecoder ( int *  handle)

Unregister Decoder.

Parameters
[in]ps32handleRegister handle (the handle obtained at the time of registration of the decoder).
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_ADEC_ReleaseStream ( int  adChn,
IMPAudioStream stream 
)

Release of the stream from the audio decoding channel.

Parameters
[in]adChnchannel number
[in]streamaudio stream pointer
Return values
0success.
non-0failure.
Remarks
See the IMP_ADEC_SendFrame function description.
Attention
no.
int IMP_ADEC_SendStream ( int  adChn,
IMPAudioStream stream,
IMPBlock  block 
)

Send audio stream to audio decoding channel.

Parameters
[in]adChnchannel number
[in]streamaudio stream
[in]blockBlocking / non blocking identifier.
Return values
0success.
non-0failure.
Remarks
sample code
1 while(1) {
2  // Get the data that needs to be decoded
3  ret = fread(buf_g711, 1, IMP_AUDIO_BUF_SIZE/2, file_g711);
4  if(ret < IMP_AUDIO_BUF_SIZE/2)
5  break;
6 
7  // Send decoding stream
8  IMPAudioStream stream_in;
9  stream_in.stream = (uint8_t *)buf_g711;
10  stream_in.len = ret;
11  ret = IMP_ADEC_SendStream(adChn, &stream_in, BLOCK);
12  if(ret != 0) {
13  IMP_LOG_ERR(TAG, "imp audio encode send frame failed\n");
14  return ret;
15  }
16 
17  // Get decoded data
18  IMPAudioStream stream_out;
19  ret = IMP_ADEC_GetStream(adChn, &stream_out, BLOCK);
20  if(ret != 0) {
21  IMP_LOG_ERR(TAG, "imp audio decoder get stream failed\n");
22  return ret;
23  }
24 
25  // Use decoded data
26  fwrite(stream_out.stream, 1, stream_out.len, file_pcm);
27 
28  // Release decoded data
29  ret = IMP_ADEC_ReleaseStream(adChn, &stream_out);
30  if(ret != 0) {
31  IMP_LOG_ERR(TAG, "imp audio decoder release stream failed\n");
32  return ret;
33  }
34 }
Attention
no.
int IMP_AENC_CreateChn ( int  aeChn,
IMPAudioEncChnAttr attr 
)

Create audio encode channel.

Parameters
[in]aeChnchannel number
[in]attrAudio encode channel attribute pointer.
Return values
0success.
non-0failure.
Remarks
sample code
1 int AeChn = 0;
2 IMPAudioEncChnAttr attr;
3 attr.type = PT_G711A;
4 attr.bufSize = 20;
5 ret = IMP_AENC_CreateChn(AeChn, &attr);
6 if(ret != 0) {
7  IMP_LOG_ERR(TAG, "Audio encode create channel failed\n");
8  return ret;
9 }
Attention
The Current SDK supports PT_G711A, PT_G711U and PT_G726 encoding.
So the use of SDK encoding, only needs attr.type = PT_G711A.
How to use a custom encoder? You need to register the encoder, the sample code is in the registration interface instructions.
int IMP_AENC_DestroyChn ( int  aeChn)

Destory audio encode channel.

Parameters
[in]aeChnchannel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
Supporting the use of IMP_AENC_CreateChn.
int IMP_AENC_GetStream ( int  aeChn,
IMPAudioStream stream,
IMPBlock  block 
)

Get the encoded stream.

Parameters
[in]aeChnchannel number
[in]streamGet audio encoding
[in]blockBlocking / non blocking identifier.
Return values
0success.
non-0failure.
Remarks
see the IMP_AENC_SendFrame function description for deeper understanding.
Attention
no.
int IMP_AENC_PollingStream ( int  AeChn,
unsigned int  timeout_ms 
)

Polling encoded audio stream cache.

Parameters
[in]AeChnAudio encoding input channel number.
[in]timeout_msPolling timeout time
Return values
0success.
non-0failure.
Remarks
no.
Attention
The current interface is used before using IMP_AENC_GetStream. After calling successfully the current interface, we will have the audio encoding data ready then you can use the IMP_AENC_GetStream to get the encoded data.
int IMP_AENC_RegisterEncoder ( int *  handle,
IMPAudioEncEncoder encoder 
)

Register encoder.

Parameters
[in]ps32handleregister handle
[in]encoderEncoder attribute structure.
Return values
0success.
non-0failure.
Remarks
sample code
1 int handle_g711a = 0;
2 IMPAudioEncEncoder my_encoder;
3 my_encoder.maxFrmLen = 1024;
4 sprintf(my_encoder.name, "%s", "MY_G711A");
5 my_encoder.openEncoder = NULL; // Encoder callback function
6 my_encoder.encoderFrm = MY_G711A_Encode_Frm; // Encoder callback function
7 my_encoder.closeEncoder = NULL; // Encoder callback function
8 
9 ret = IMP_AENC_RegisterEncoder(&handle_g711a, &my_encoder);
10 if(ret != 0) {
11  IMP_LOG_ERR(TAG, "IMP_AENC_RegisterEncoder failed\n");
12  return ret;
13 }
14 
15 // use encoder
16 int AeChn = 0;
17 IMPAudioEncChnAttr attr;
18 attr.type = handle_g711a; // The encoder type is equal to the value of the handle_g711a returned by the successfully registered.
19 attr.bufSize = 20;
20 ret = IMP_AENC_CreateChn(AeChn, &attr);
21 if(ret != 0) {
22  IMP_LOG_ERR(TAG, "imp audio encode create channel failed\n");
23  return ret;
24 }
Attention
After registration, the use of the method and the use of SDK in the encoder are all the same. (After registration, clients' methods and SDK prebuilt functions are considered as the SDK functions, that means the clients can change the content of the SDK as they wish)
int IMP_AENC_ReleaseEncoder ( int *  handle)

Release encoder.

Parameters
[in]ps32handleRegister handle (the handle obtained at the time of registration of the encoder).
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AENC_ReleaseStream ( int  aeChn,
IMPAudioStream stream 
)

Releases the stream from the audio encoding channel.

Parameters
[in]aeChnchannel number
[in]streamGet audio stream pointer
Return values
0success.
non-0failure.
Remarks
see the IMP_AENC_SendFrame function description.
Attention
no.
int IMP_AENC_SendFrame ( int  aeChn,
IMPAudioFrame frm 
)

Send audio encoding audio frame.

Parameters
[in]aeChnchannel number
[in]frmAudio frame structure pointer.
Return values
0success.
non-0failure.
Remarks
sample code
1 while(1) {
2  // Read a frame of data
3  ret = fread(buf_pcm, 1, IMP_AUDIO_BUF_SIZE, file_pcm);
4  if(ret < IMP_AUDIO_BUF_SIZE)
5  break;
6 
7  // encode
8  IMPAudioFrame frm;
9  frm.virAddr = (uint32_t *)buf_pcm;
10  frm.len = ret;
11  ret = IMP_AENC_SendFrame(AeChn, &frm);
12  if(ret != 0) {
13  IMP_LOG_ERR(TAG, "imp audio encode send frame failed\n");
14  return ret;
15  }
16 
17  // Get encode stream
18  IMPAudioStream stream;
19  ret = IMP_AENC_GetStream(AeChn, &stream, BLOCK);
20  if(ret != 0) {
21  IMP_LOG_ERR(TAG, "imp audio encode get stream failed\n");
22  return ret;
23  }
24 
25  // Use encode stream
26  fwrite(stream.stream, 1, stream.len, file_g711);
27 
28  // Release encode stream
29  ret = IMP_AENC_ReleaseStream(AeChn, &stream);
30  if(ret != 0) {
31  IMP_LOG_ERR(TAG, "imp audio encode release stream failed\n");
32  return ret;
33  }
34 }
Attention
no.
int IMP_AI_Disable ( int  audioDevId)

Disable audio input device.

Parameters
[in]audioDevIdAudio device number
Return values
0success.
non-0failure.
Remarks
no.
Attention
It supports the use of IMP_AI_Enable. IMP_AI_Disable must be performed before putting the system in sleeping mode.
int IMP_AI_DisableAec ( int  aiDevId,
int  aiChn 
)

Disable audio echo cancellation feature.

Parameters
[in]aiDevIdAudio input device number
[in]aiChnaudio input channel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_DisableAecRefFrame ( int  audioDevId,
int  aiChn,
int  audioAoDevId,
int  aoChn 
)

Close access to the reference frame.

Parameters
[in]audioDevIdaudio device number.
[in]aiChnaudio input channel number.
[in]audioAoDevIdaudio output device number.
[in]aoChnaudio output channel number.
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_DisableAgc ( void  )

Disable AI automatic gain feature.

Parameters
no.
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_DisableChn ( int  audioDevId,
int  aiChn 
)

Disable audio input channel.

Parameters
[in]audioDevIdAudio device number
[in]aiChnAudio input channel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
It supports the use of IMP_AI_EnableChn.
int IMP_AI_DisableHpf ( void  )

Disable AI high pass filtering function.

Parameters
no.
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_DisableNs ( void  )

Disable noise suppression.

Parameters
no.
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_Enable ( int  audioDevId)

Enable audio input device.

Parameters
[in]audioDevIdAudio device number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_EnableAec ( int  aiDevId,
int  aiChn,
int  aoDevId,
int  aoChn 
)

Enable audio echo cancellation feature of the specified audio input and audio output.

Parameters
[in]aiDevIdNeed to perform audio echo cancellation of the audio input device number.
[in]aiChnNeed to perform audio echo cancellation of the audio input channel number.
[in]aoDevIdNeed to perform audio echo cancellation of the audio output device number.
[in]aoChnNeed to perform audio echo cancellation of the audio output channel number.
Return values
0success.
non-0failure.
Remarks
The Audio echo cancellation for different devices and different packages will have different sound effects.
Adaptive support is not available in Audio Echo Cancellation (the AEC is not automatically configured), so for different devices there will be different echo cancellation parameters,
Only use the functional effect is not really good.
The parameter file of the Audio echo cancellation is located in the /etc/webrtc_profile.ini configuration file.
The profile format is as follows (Main need to debug the three parameters):
[Set_Far_Frame]
Frame_V=0.3
[Set_Near_Frame]
Frame_V=0.1
delay_ms=150
[Set_Far_Frame] represents the remote(far-end) parameter, the SPK represents the playback data parameters.
Fram_V represents audio amplitude scaling, the playback data can be adjusted by adjusting these parameters (this is used only for echo cancellation).
[Set_Near_Frame] represents the proximal(near-end) parameter, the MIC represents record data parameters.
Fram_V represents the audio amplitude ratio, the adjustment of these parameters can adjust the amplitude of the recording data (this is only used for echo cancellation).
Delay_ms, because of the delay between software and hardware, and the position between the SPK and MIC(they are placed at a certain distance), the SPK playback data will be processed by the MIC again. So, there will be some delay because the SPK data will have some impact on the MIC data.
This time represents the time difference of the playback data in data recording. (delay to assure that there won't be any echo at all).
Attention
In fact, the interface will only check for aiDevId and aiChn, but it is better to enabele these two channels at the same time and then call the current one.
when the audio input channel is closed, the Audio Echo Cancellation feature also is turned off. In case of using it again, you will have to turn it on.
int IMP_AI_EnableAecRefFrame ( int  audioDevId,
int  aiChn,
int  audioAoDevId,
int  aoChn 
)

Open access reference frame.

Parameters
[in]audioDevIdaudio device number.
[in]aiChnaudio input channel number.
[in]audioAoDevIdaudio output device number.
[in]aoChnaudio output channel number.
Return values
0success.
non-0failure.
Remarks
Use this current interface before using IMP_AI_GetFrameAndRef.
Attention
no.
int IMP_AI_EnableAgc ( IMPAudioIOAttr attr,
IMPAudioAgcConfig  agcConfig 
)

Enable automatic gain of audio input.

Parameters
[in]attrRequires automatic gain of the audio attribute.
[in]agcConfigAutomatic gain parameter configuration, configuration magnification.
Return values
0success.
non-0failure.
Remarks
Note the configuration of the AGC. agcConfig amplification's main parameters have their own configuration, check the specific gain IMPAudioAgcConfig instructions.
Note that AGC can gain sound amplification, but if the gain parameter is not appropriate, it will lead to broken noise, please adjust carefully the parameters.
Attention
Audio echo cancellation contains the AGC function, which means it is not required to perform automatic gain if the echo cancellation is enabled.
int IMP_AI_EnableChn ( int  audioDevId,
int  aiChn 
)

Enable audio input channel.

Parameters
[in]audioDevIdAudio device number
[in]aiChnAudio input channel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
Must first enable device.
int IMP_AI_EnableHpf ( IMPAudioIOAttr attr)

Enable audio input for high pass filtering.

Parameters
[in]attrneed high pass filtering of audio attribute.
Return values
0success.
non-0failure.
Remarks
no.
Attention
Audio echo cancellation contains the HPF function, if Audio Echo Cancellation is enabled, so HPF will be automatically enabled.
int IMP_AI_EnableNs ( IMPAudioIOAttr attr,
int  mode 
)

Enable specified audio input noise suppression.

Parameters
[in]attrNoise suppression is required for the audio attribute.
[in]modeNoise suppression level 0 ~ 3, see Level_ns.
Return values
0success.
non-0failure.
Remarks
The mode parameter of noise suppression represents the noise suppression level (range [0 ~ 3]), the higher the level, the cleaner the noise suppression.
However, The cleaner the noise is, more details of the sound will be lost, here we have a contradiction so we need to make tradeoff while processing the noise suppression.
Attention
Audio echo cancellation contains the noise suppression function, if the audio echo cancellation is enabled, it is not required to enable the noise suppression.
int IMP_AI_GetChnParam ( int  audioDevId,
int  aiChn,
IMPAudioIChnParam chnParam 
)

Set audio input channel parameters.

Parameters
[in]audioDevIdaudio device number
[in]aiChnaudio input channel number
[out]chnParamaudio channel parameters
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_GetFrame ( int  audioDevId,
int  aiChn,
IMPAudioFrame frm,
IMPBlock  block 
)

Get audio frame.

Parameters
[in]audioDevIdAudio device number
[in]aiChnAudio input channel number
[out]frmAudio frame structure pointer.
[in]blockBlocking / non blocking identifier.
Return values
0success.
non-0failure.
Remarks
Sample code
1 IMPAudioFrame frm;
2 // Get audio frame
3 ret = IMP_AI_GetFrame(devID, chnID, &frm, BLOCK);
4 if(ret != 0) {
5  IMP_LOG_ERR(TAG, "Audio Get Frame Data error\n");
6  return ret;
7 }
8 
9 fwrite(frm.virAddr, 1, frm.len, record_file); // use audio frame data
10 
11 // Release audio frame
12 ret = IMP_AI_ReleaseFrame(devID, chnID, &frm);
13 if(ret != 0) {
14  IMP_LOG_ERR(TAG, "Audio release frame data error\n");
15  return ret;
16 }
Attention
no.
int IMP_AI_GetFrameAndRef ( int  audioDevId,
int  aiChn,
IMPAudioFrame frm,
IMPAudioFrame ref,
IMPBlock  block 
)

Get audio frame and output reference frame.

Parameters
[in]audioDevIdaudio device number.
[in]aiChnaudio input channel number.
[out]frmaudio frame structure pointer.
[out]refreference frame structure pointer.
[in]blockblock and non-block identitifier.
Return values
0success.
non-0failure.
Remarks
Sample code
1 IMPAudioFrame frm;
2 IMPAudioFrame ref;
3 // Get audio frame and output reference frame
4 ret = IMP_AI_GetFrameAndRef(devID, chnID, &frm, &ref, BLOCK);
5 if(ret != 0) {
6  IMP_LOG_ERR(TAG, "Audio Get Frame Data error\n");
7  return ret;
8 }
9 
10 fwrite(frm.virAddr, 1, frm.len, record_file); // Use audio frame data
11 fwrite(ref.virAddr, 1, ref.len, ref_file); // Use audio reference frame
12 
13 // Release audio frame
14 ret = IMP_AI_ReleaseFrame(devID, chnID, &frm);
15 if(ret != 0) {
16  IMP_LOG_ERR(TAG, "Audio release frame data error\n");
17  return ret;
18 }
Attention
no.
int IMP_AI_GetGain ( int  audioDevId,
int  aiChn,
int *  aiGain 
)

Get AI gain value.

Parameters
[in]audioDevIdAudio input device number
[in]aiChnAudio input channel number
[out]aiGainaudio input gain
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_GetPubAttr ( int  audioDevId,
IMPAudioIOAttr attr 
)

Get the attribute of the audio input device.

Parameters
[in]audioDevIdAudio device number
[out]attrAudio device attribute pointer
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_GetVol ( int  audioDevId,
int  aiChn,
int *  vol 
)

Get the volume of the audio input.

Parameters
[in]aiDevIdAudio input device number
[in]aiChnAudio input channel number
[out]volaudio input volume
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AI_PollingFrame ( int  audioDevId,
int  aiChn,
unsigned int  timeout_ms 
)

Polling audio stream cache.

Parameters
[in]audioDevIdAudio device number
[in]aiChnAudio input channel number
[in]timeout_msPolling timeout time.
Return values
0success.
non-0failure.
Remarks
no.
Attention
Use the interface before using IMP_AI_GetFrame, and when the interface is called successfully, then the audio data is ready, and you can use IMP_AI_GetFrame to get audio data.
int IMP_AI_ReleaseFrame ( int  audioDevId,
int  aiChn,
IMPAudioFrame frm 
)

Release audio frame.

Parameters
[in]audioDevIdAudio device number
[in]aiChnAudio input channel number
[in]frmAudio frame structure pointer
Return values
0success.
non-0failure.
Remarks
no.
Attention
It supports the use of IMP_AI_GetFrame.
int IMP_AI_SetChnParam ( int  audioDevId,
int  aiChn,
IMPAudioIChnParam chnParam 
)

Set audio input channel parameters.

Parameters
[in]audioDevIdAudio device number
[in]aiChnaudio input channel number
[in]chnParamaudio frame structure pointer
Return values
0success.
non-0failure.
Remarks
sample code
1 int chnID = 0;
2 IMPAudioIChnParam chnParam;
3 chnParam.usrFrmDepth = 20;
4 ret = IMP_AI_SetChnParam(devID, chnID, &chnParam);
5 if(ret != 0) {
6  IMP_LOG_ERR(TAG, "set ai %d channel %d attr err: %d\n", devID, chnID, ret);
7  return ret;
8 }
Attention
Supporting the use of IMP_AI_EnableChn.
int IMP_AI_SetGain ( int  audioDevId,
int  aiChn,
int  aiGain 
)

Set audio input gain.

Parameters
[in]audioDevIdAudio input device number
[in]aiChnAudio input channel number
[out]aiGainAudio input gain, range [0 ~ 31].
Return values
0success.
non-0failure.
Remarks
no.
Attention
aiGain range of [0 ~ 31], if the input value is less than 0, then the value of aiGain will be set to 0 if the value is greater than 31, the value of aiGain will be set to 31
int IMP_AI_SetPubAttr ( int  audioDevId,
IMPAudioIOAttr attr 
)

Set audio input device attribute.

Parameters
[in]audioDevIdAudio device number
[in]attrAudio device attribute pointer
Return values
0success.
non-0failure.
Remarks
Sample code
1 int devID = 1;
2 IMPAudioIOAttr attr;
3 attr.samplerate = AUDIO_SAMPLE_RATE_8000;
4 attr.bitwidth = AUDIO_BIT_WIDTH_16;
5 attr.soundmode = AUDIO_SOUND_MODE_MONO;
6 attr.frmNum = 20;
7 attr.numPerFrm = 400;
8 attr.chnCnt = 1;
9 ret = IMP_AI_SetPubAttr(devID, &attr);
10 if(ret != 0) {
11  IMP_LOG_ERR(TAG, "Set Audio in %d attr err: %d\n", devID, ret);
12  return ret;
13 }
Attention
Need to be called before IMP_AI_Enable.
int IMP_AI_SetVol ( int  audioDevId,
int  aiChn,
int  aiVol 
)

ACODEC configuration.

Set audio input volume.

Parameters
[in]aiDevIdaudio input device number
[in]aiChnaudio input channel number
[in]aiVolaudio input volume
Return values
0success.
non-0failure.
Remarks
volume in the range of [-30 ~ 120]. - 30 represents mute, 120 is to amplify the sound of to 30dB, step 0.5dB.
60 is to set the volume to a critical point. In this case, the software does not increase or decrease the volume, when the volume value is less than 60, for each drop of 1, the volume is decreased by 0.5dB; when the volume value is greater than 60, for each rise of 1, the volume is increased by 0.5dB.

sample code

1 int volume = 60;
2 ret = IMP_AI_SetVol(devID, chnID, volume);
3 if(ret != 0) {
4  IMP_LOG_ERR(TAG, "Audio Record set volume failed\n");
5  return ret;
6 }
Attention
If the input of the aiVol exceeds the range of [-30 ~ 120]. when it is less than -30 it will take -30 as value, more than 120 it will be considered as 120.
int IMP_AI_SetVolMute ( int  audioDevId,
int  aiChn,
int  mute 
)

Set audio input mute.

Parameters
[in]aiDevIdAudio input device number
[in]aiChnAudio input channel number
[out]muteAudio input mute flag, mute = 0: off mute, mute = 1: on mute.
Return values
0success.
non-0failure.
Remarks
By calling the interface, it can be muted immediately.
Attention
no.
int IMP_AO_CacheSwitch ( int  audioDevId,
int  aoChn,
int  cache_en 
)

close audio play cache

Parameters
[in]audioDevIdaudio device number.
[in]aoChnaudio output channel number.
[in]cache_enswitch of control cache.
Return values
0success
non-0failure.
Remarks
no
Attention
no.
int IMP_AO_ClearChnBuf ( int  audioDevId,
int  aoChn 
)

Clear the current audio data cache in the audio output channel.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_Disable ( int  audioDevId)

Disable audio output device.

Parameters
[in]audioDevIdaudio device number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_DisableAgc ( void  )

Disable AO automatic gain feature.

Parameters
no.
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_DisableChn ( int  audioDevId,
int  aoChn 
)

Disable audio output channel.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_DisableHpf ( void  )

Disable AO high pass filtering function.

Parameters
no.
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_Enable ( int  audioDevId)

Enable audio output device.

Parameters
[in]audioDevIdaudio device number
Return values
0success.
non-0failure.
Remarks
no.
Attention
The IMP_AO_SetPubAttr. must be called before
int IMP_AO_EnableAgc ( IMPAudioIOAttr attr,
IMPAudioAgcConfig  agcConfig 
)

Enable audio output automatic gain feature.

Parameters
[in]attrneed automatic gain of the audio attribute.
[in]agcConfigautomatic gain parameter configuration, configuration magnification.
Return values
0success.
non-0failure.
Remarks
agcConfig amplification's main parameters have their own configuration, check the specific gain IMPAudioAgcConfig instructions.
Note that AGC can gain sound amplification, but if the gain parameter is not appropriate, it will lead to broken noise, please adjust carefully the parameters.
Attention
Audio echo cancellation contains the AGC function, which means it is not required to perform automatic gain if the echo cancellation is enabled.
int IMP_AO_EnableChn ( int  audioDevId,
int  aoChn 
)

Enable audio output channel.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_EnableHpf ( IMPAudioIOAttr attr)

Enable audio output for high pass filtering.

Parameters
[in]attrneed high pass filtering of audio attribute.
Return values
0success.
non-0failure.
Remarks
no.
Attention
Audio echo cancellation contains the HPF function, if audio echo cancellation is enabled, so you do not need to enable HPF.
int IMP_AO_GetGain ( int  audioDevId,
int  aoChn,
int *  aoGain 
)

Get audio output gain.

Parameters
[in]audioDevIdaudio output device number.
[in]aoChnaudio output channel number.
[out]aoGainaudio output gain.
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_GetPubAttr ( int  audioDevId,
IMPAudioIOAttr attr 
)

Get audio input and output device attribute.

Parameters
[in]audioDevIdaudio device number
[out]attraudio output device attribute pointer
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_GetVol ( int  audioDevId,
int  aoChn,
int *  vol 
)

Get audio output channel volume.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
[out]aoVolaudio output volume
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_PauseChn ( int  audioDevId,
int  aoChn 
)

Pause audio output channel.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_QueryChnStat ( int  audioDevId,
int  aoChn,
IMPAudioOChnState status 
)

Query the current audio data cache status in the audio output channel.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
[out]statusCache state structure pointer.
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_ResumeChn ( int  audioDevId,
int  aoChn 
)

Resume audio output channel.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_SendFrame ( int  audioDevId,
int  aoChn,
IMPAudioFrame data,
IMPBlock  block 
)

Send audio output frame.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
[in]dataaudio frame sturcture pointer
[in]blockBlocking / non blocking identifier.
Return values
0success.
non-0failure.
Remarks
sample code
1 while(1) {
2  size = fread(buf, 1, IMP_AUDIO_BUF_SIZE, play_file);
3  if(size < IMP_AUDIO_BUF_SIZE)
4  break;
5 
6  IMPAudioFrame frm;
7  frm.virAddr = (uint32_t *)buf;
8  frm.len = size;
9  ret = IMP_AO_SendFrame(devID, chnID, &frm, BLOCK);
10  if(ret != 0) {
11  IMP_LOG_ERR(TAG, "send Frame Data error\n");
12  return ret;
13  }
14 }
Attention
no.
int IMP_AO_SetGain ( int  audioDevId,
int  aoChn,
int  aoGain 
)

Set audio output gain.

Parameters
[in]audioDevIdAudio output device number
[in]aoChnaudio output channel number
[out]aoGainAudio output gain, range [0 ~ 0xcb].
Return values
0success.
non-0failure.
Remarks
no.
Attention
aoGain range of [0 ~ 31], if the input value is less than 0, then the value of aoGain will be set to 0.
aoGain if the value is greater than 31, the value of aiGain will be set to 31
int IMP_AO_SetPubAttr ( int  audioDevId,
IMPAudioIOAttr attr 
)

Set audio input and output device attribute.

Parameters
[in]audioDevIdaudio device number
[in]attraudio output device attribute pointer
Return values
0success.
non-0failure.
Remarks
no.
Attention
no.
int IMP_AO_SetVol ( int  audioDevId,
int  aoChn,
int  aoVol 
)

Set audio output channel volume.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
[in]aoVolaudio output volume
Return values
0success.
non-0failure.
Remarks
volume in the range of [-30 ~ 120]. - 30 represents mute, 120 is to amplify the sound of to 30dB, step 0.5dB.
60 is to set the volume to a critical point. In this case, the software does not increase or decrease the volume, when the volume value is less than 60, for each drop of 1, the volume is decreased by 0.5dB; when the volume value is greater than 60, for each rise of 1, the volume is increased by 0.5dB.
Attention
If the input of the aiVol exceeds the range of [-30 ~ 120], when it is less than -30 it will take -30 as value , more than 120 it will be 120.
int IMP_AO_SetVolMute ( int  audioDevId,
int  aoChn,
int  mute 
)

Set audio output mute.

Parameters
[in]audioDevIdaudio device number
[in]aoChnaudio output channel number
[out]muteAudio output mute flag, mute = 0: off mute, mute = 1: on mute.
Return values
0success.
non-0failure.
Remarks
By calling the interface, it can be muted immediately.
Attention
no.
int IMP_AO_Soft_Mute ( int  audioDevId,
int  aoChn 
)

Output soft mute control.

Parameters
[in]audioDevIdAudio output device number.
[in]aoChnAudio input channel number.
Return values
0success.
non-0failure.
Remarks
when this interface is called, it wil not be directly in silence mode from normal playback state. It will slow down gradually, until it reaches the silence mode.
Attention
no.
int IMP_AO_Soft_UNMute ( int  audioDevId,
int  aoChn 
)

Output soft unmute control.

Parameters
[in]audioDevIdAudio output device number.
[in]aoChnAudio input channel number.
Return values
0success.
non-0failure.
Remarks
when this interface is called, it will not directly restore the current volume. It will gradually increase the volume from silence mode until the volume reaches a set of good volume.
Attention
no.

Variable Documentation

int CompressionGaindB

Set the maximum gain value, [0, 90], 0 represents no gain, the greater the value, the higher the gain.

int TargetLevelDbfs

Gain level, the value of [0, 31], this refers to the target volume level, the unit is dB, is negative value.

The smaller the value, the greater the volume.