A detailed introduction to embedded audio processing workflow development

Publisher:快乐舞步Latest update time:2024-02-20 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

If you want to compile and test directly on your PC, you can use the following command:

mkdir _install_linux_x86 ./autogen.sh ./configure --prefix=$PWD/_install_linux_x86 make -j4 make install

(5) fdk-aac application

Here is a brief introduction on how to use fdk-aac to encode PCM files into AAC format files, and then use fdk-aac to decode AAC into PCM format data.

There is a test-encode-decode.c file under the fdk-aac source code. It is a demo based on wav format files. If PCM and AAC data are stored in wav format, you can directly refer to the official demo.

I am using the PCM bare stream introduced above for encoding and decoding.

(a) PCM encoding to AAC

Because we are using PCM raw stream, we cannot read any stream information from the file, so we need to fill in the PCM stream information ourselves:

int aot, afterburner, eld_sbr, vbr, bitrate, adts, sample_rate, channels,mode; /**Parameter settings**/ aot = 2; /**Audio object type 2 MPEG-4 AAC Low Complexity.**/ afterburner = 0; /**Whether to enable the analysis and synthesis algorithm, which can improve the encoding quality, but will consume resources**/ eld_sbr = 0 ; /**Spectral Band Replication spectrum display**/ vbr = 0; /**Variable bit rate configuration**/ bitrate = 48000; /**Encoding bit rate**/ adts = 1; /**Whether to transmit**/ sample_rate = 48000; /**Sampling rate**/ channels = 2; /**Channel**/

The AAC format to be encoded can be set through aacEncoder_SetParam(encoder, AACENC_TRANSMUX, 2). The supported formats are:

- 0: raw access units - 1: ADIF bitstream format - 2: ADTS bitstream format - 6: Audio Mux Elements (LATM) withmuxConfigPresent = 1 - 7: Audio Mux Elements (LATM) withmuxConfigPresent = 0, out of band StreamMuxConfig - 10: Audio Sync Stream (LOAS) */

(b) AAC decoding to PCM

Here we introduce how to decompress AAC files encoded in ADTS format into PCM

To decode an AAC file, we first need to be able to detect the position and length of the audio frame in the AAC file, so we first need to parse the AAC ADTS header information. The header structure is defined as follows:

typedefstruct adts_fixed_header { unsigned short syncword:12; unsignedchar id: 1; unsignedchar layer:2; unsignedchar protection_absent: 1; unsignedchar profile: 2; unsignedchar sampling_frequency_index: 4; unsignedchar private_bit: 1; unsignedchar channel_configuration:3; unsignedchar original_copy:1; unsignedchar home: 1; } adts_fixed_header; // length : 28 bits typedefstruct adts_variable_header { unsignedchar copyright_identification_bit:1; unsignedchar copyright_identification_start:1; unsigned short aac_frame_length:13; unsigned short adts_buffer_fullness:11; unsignedchar number_of_raw_data_blocks_in_frame:2; } adts_variable_header; // length : 28 bits

The parsing method is as follows:

memset(&fixed_header, 0, sizeof(adts_fixed_header)); memset(&variable_header, 0, sizeof(adts_variable_header)); get_fixed_header(headerBuff, &fixed_header); get_variable_header(headerBuff, &variable_header);

When decoding, you also need to pay attention to the need to use aacDecoder_ConfigRaw to configure PCM information. The demo obtains it through info.confBuf. This value is only available during encoding, so this value needs to be set according to the actual parameters:

unsignedchar conf[] = {0x11, 0x90}; //AAL-LC 48kHz 2 channle unsignedchar* conf_array[1] = { conf }; unsignedint length = 2; if (AAC_DEC_OK != aacDecoder_ConfigRaw(decoder, conf_array, &length)) { printf("error: aac config fail "); exit(1); }

The complete project files are as follows:

biao@ubuntu:~/test/faac/fdk-aac-x86$ tree . ├── 48000_16bits_2ch.pcm ├── adts.c ├── adts.h ├── decode_48000_16bits_2ch.pcm ├── include │ └── fdk-aac │ ├── aacdecoder_lib.h │ ├── aacenc_lib.h │ ├── FDK_audio.h │ ├── genericStds.h │ ├── machine_type.h │ └── syslib_channelMapDescr.h ├── lib │ ├── libfdk-aac.a │ ├── libfdk-aac.la │ ├── libfdk-aac.so -> libfdk-aac.so.2.0.2 │ ├── libfdk-aac.so.2 -> libfdk-aac.so.2.0.2 │ ├── libfdk-aac.so.2.0. 2 │ └── pkgconfig │ └── fdk-aac.pc ├── Makefile ├── out.aac ├── out_ADIF.aac ├── out_adts.aac ├── out_RAW.aac └── test_faac.c 4 directories, 22 files biao@ubuntu:~/ test/faac/fdk-aac-x86$


Conclusion

Embedded audio development involves a lot of content, and each function alone involves a lot of knowledge points.

The above is just a brief introduction to their concepts for easy use.


[1] [2]
Reference address:A detailed introduction to embedded audio processing workflow development

Previous article:Smart home system based on CW32
Next article:YXC active crystal oscillator provides clock solution for power amplifier and audio system

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号