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.
Previous article:Smart home system based on CW32
Next article:YXC active crystal oscillator provides clock solution for power amplifier and audio system
- Popular Resources
- Popular amplifiers
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- MCU model confirmation and decryption
- [Zero-knowledge ESP8266 tutorial] Quick start 25 Blynk control RGB LED
- Need a 10uh inductor, ESR < 0.2Ω, saturation current > 0.8A
- Ti DSP optimization basic strategy
- Bluetooth Protocol Stack-01
- Thanks to shihuntaotie netizen for donating a large number of development boards!
- Scattered Noise Figure
- EEWORLD University Hall----Li Hongyi: The next step of machine learning
- Digital Integrated Circuit Design: From VLSI Architecture to CMOS Manufacturing.pdf
- MSP430 JTAG pin diagram