HiSilicon hi35xx----Audio Module Usage Summary

Source: Internet
Author: User

The audio module consists of four sub-modules, which include input, audio, audio, and audio decoding. Audio input and

The output module realizes the audio input and output function through the control of the HI35XX chip SIO interface. The audio encoding and decoding module provides audio codec functions in the G711, G726, and ADPCM formats, and supports recording and playback of original audio files in LPCM format.

The audio input and output interface SIO (Sonic input/output) is used to connect with audio Codec to complete sound recording and playback.

For each SIO interface audio input and audio output functions, the software is administered using AI and AO two modules, called AI devices and AO devices, and numbered according to the SIO serial number. For example, the software devices corresponding to the SIO0 interface are AiDev0 and AoDev0, respectively.

HI3518 recording and playback principle:

Recording: The original audio signal is given in the form of an analog signal, and is converted to a digital signal by a certain sample rate and sampling accuracy via the audio Codec. The Audio CODEC transmits the digital signal to the SIO interface in I2S timing or PCM timing, SIO supports multiplexing receive mode. The HI35XX chip uses DMAC to save audio data from the SIO interface to memory for recording operations.

Playback: The HI35XX chip uses DMAC to transfer in-memory data to the SIO interface. The SIO interface sends data to the Audio CODEC via the i2s timing or PCM timings. The Audio Codec completes the conversion of the digital signal to the analog signal and outputs the analog signal.

HI35XX Audio part of the encoding type G711, G726, Adpcm_dvi4 and Adpcm_org_dvi4 is used hard-coded, Adpcm_ima is using the CPU software decoding, wherein the HI3518/HI3516C chip does not have a hardware encoding module, All encoding methods use software encoding, while all decoding functions are based on the independent package of the Hai-Si audio codec library, the core decoder works in the user state, using the CPU software decoding . The SDK supports the binding interface of the SYS module, binds an AI channel to the Aenc channel, implements the recording encoding function, or binds a ADEC channel to the AO channel for decoding and playback functions.

Encoding the G711, G726, ADPCM formats using the HiSilicon Speech codec library, the encoded stream follows the frame structure described in the table below, which is filled with 4 bytes of frame head before the net load data per frame stream data, and the corresponding frame header information is required to decode the above format using the speech codec library.

The 4-byte frame header content is the value in the following array:

static char aryheard[4] = {0,1,160,0};//hisi Audio header

When using the ACODEC library for audio decoding, it is necessary to combine the contents of this array into the head position of the packet before each packet of audio data is sent to the decoding channel, otherwise the decoding error occurs.

The sampling rate of G711, G726, ADPCM encoding protocol is 8KHz.

Among them, HI3518/HI3516C uses the internal audio codec. HI3518A/HI3516C supports dual channel, left and right channel input, left and right channel output. HI3518C only supports mono, left channel input, left channel output.

The maximum number of channels supported by the audio AI and AO is 16 channels (where the hi3518/hi3516c chip is limited by the built-in codec, only 2 channels are supported), and the channel is configured to be even if the AI and AO devices are configured.

The hi3518/hi3516c only supports 16bit bit width.

The HI3518A/HI3518C/HI3516C provides a built-in audio Codec, and on the inside of the chip to the SIO0 interface, that is, the SIO0 interface only through the built-in audio Codec to complete the sound playback and recording. Because AUDIOCODEC cannot send synchronous clocks, the SIO0 interface can only be configured as main mode (master) for I2S timing. Users need to properly configure the SIO0 and audio Codec docking timings to receive or send audio data.

Audio Codec is divided into analog and digital parts. The analog part can be selected by a mic input (micin) or linear input (LineIn) via analog mixing (MICPGA), which supports gain adjustment for analog mixing. The digital part has an ADC and a DAC to perform the conversion between the analog and digital signals, and the volume can be individually adjusted. The volume adjustment of the part and the digital part can be synthesized when the user is adjusting the volume, and it is recommended to adjust the analog part volume first.

The Audio Codec supports de-emphasis filtering, pop tone suppression, and high pass filtering, which are enabled by default.

The user interface of the Audio Codec is shown in the form of an IOCTL, as follows:

int ioctl (int fd,

unsigned long cmd,

......

);

This function is a Linux standard interface with variable parameter characteristics. In Audio Codec, however, only 3 parameters are required. Therefore, its grammatical form is equivalent to:

int ioctl (int fd,

unsigned long cmd,

Cmd_data_type *cmddata);

The cmd_data_type changes with the parameter CMD.

In summary, the HI3518C audio subsystem should be initialized with the following software configuration:

Audio encoding recording process :

1, audio input properties (see aio_attr_s structure);

2, configure audio encoding, decoding module (ACODEC);

3. Set AI device properties, enable AI device, enable AI channel, (Enable AI noise suppression, enable AI resampling, both optional). );

4, according to the Audio encoding protocol to create audio coding channels;

5, binding audio encoding channel to the audio input channel;

6, HI_MPI_AENC_GETFD (Aenc_chn Aechn) to obtain the audio encoding channel FD;

7, Hi_mpi_aenc_getstream from the encoded channel to obtain the audio data after encoding;

8, the user saves or forwards this data.

audio decoding playback process :

1, audio output properties (see aio_attr_s structure) initialization;

2, configure audio encoding, decoding module (ACODEC);

3, according to the Audio encoding protocol to create audio decoding channel;

4. Set AO device properties, enable AO device, enable AO Channel (this option is enabled for AO resampling);

5, binding the audio output channel to the audio decoding channel;

6. Add 4 bytes of the Hai-Si audio protocol header to the audio data header to be sent to each packet;

7, Hi_mpi_adec_sendstream to the audio decoding channel sent after the combination of audio packets;

8, play the sound.

The hi35xx SIO supports extended multi-receiver i2s and PCM interface timing, and the configuration of the timing mode selection, synchronization clock, sampling bit width, etc. of the docking CODEC must be consistent with the configuration of the hi35xx SIO, otherwise the correct data may not be collected. Audio_point_num = 320 In the code above, the audio data per packet is 324 bytes (320 bytes of payload Data + 4 bytes HiSilicon audio data header) from the audio encoded channel via the call Port Hi_mpi_aenc_getstream. When decoding playback with ACODEC, the data length must be 324 bytes (320 bytes of net charge data + 4 byte HiSilicon audio header) each time the audio data is sent to the audio decoding channel by calling Hi_mpi_adec_sendstream.

After the audio initialization configuration is complete, the Acodec module needs to be configured first, when configuring the Acodec module, note:

1. To turn off the micin mute (MUTE) function.

2, input equipment selection LineIn.

Here I have a little doubt, the input of the device is clearly connected to the mic, I started without thinking on the choice of micin to configure ACODEC, but the audio encoding process after the acquisition of audio data playback only "sand rustling" background sound, not hear the voice of the microphone side, tangled for two days, Other parameters determine no problem, try to change the micin to LineIn, sound OK, no language ...

At present, the collected sound and decoding sound are very clear, just a little bit, and then try to adjust the audio listening and speaking volume by the various gain adjustment commands given by the IOCTL and the corresponding ACODEC module.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.