mp3 audio format, the most popular


Free Download Mp4Gain
picture

mp3 audio format, the most popular

mp3 audio format, the most popular

With the rapid development of file compression technology, MP3 has become the most popular music format today.

mp3 audio format, the most popular

MP3 File Format Analysis MP3 file data is made up of multiple frames, and the frame is the smallest unit of the MP3 file. Each frame consists of a frame header, additional information, and sound data. The playback time of each frame is 0.026 seconds, and its duration varies with the bit rate. Some MP3 files have extra bytes at the end to store description information for non-audio data. The structure of the MP3 file is shown in Figure 2. 3.1 Frame header format The frame header is 4 bytes long. For fixed bitrate MP3 files, the frame header format of all frames is the same. The data structure is as follows: typedef FrameHeader{ unsigned int sync:11;//Sync information unsigned int version:2 ;//version unsigned int layer:2;//layer unsigned int protection:1;//CRC check unsigned int bitrate:4;//unsigned bitrate int frequency:2;//unsigned frequency int padding:1;//unsigned frame length setting int private:1;//unsigned reserved word int mode:2; //unsigned channel mode int mode extension:2;//unsigned extended mode int copyright:1;//unsigned copyright int original:1 ;//unsigned original logo int emphasis:2;//emphasis mode }HEADER, *LPHEADER; See Table 1 for a description of the 4 byte frame header. Table 1 Explanation of the use of MP3 frame header bytes Name Length (bits) Description Synchronization information 11 All bits in the 1st and 2nd byte are 1, and the 1st byte is always FF. Version 200-MPEG 2. 5 01-undefined 10-MPEG 2 11-MPEG 1 layer 2 00-undefined 01-Layer 3 10-Layer 2 11-Layer 1 CRC check 1 0-check 1-no check Bit rate 4 The third bit Tuple sampling rate, the unit is kbps, such as MPEG-1 Layer 3, 64 kbps, the value is 0101. Frequency 2 Sampling frequency, for MPEG-1: 00-44.1 kHz 01-48 kHz 10 -32 kHz 11-setting frame length undefined 1 is used to set the length of the file header, 0-no setting, 1-setting, the specific setting calculation method see below. Reserved word 1 is not used. Channel Mode 2 The fourth byte indicates the channel, 00-Stereo 01-Joint Stereo 10-Dual Channel 11-Mono Expansion Mode 2 Only used when the channel mode is 01. Copyright 1 Whether the file is legal or not, 0-Illegal 1-Original logo legal 1 If original, 0-Not original 1-Original emphasis method 2 Used for classification of sound compensation after noise reduction and compression, which is rarely used and is it may not work in the future. 00-Undefined 01-50/15ms 10-Reserved 11-CCITT J.17 MP3 frame length depends on bit rate and frequency, the calculation formula is: frame length = 144×bit rate∕ frequency+padding For example: bit rate is 64kbps, frequency is 44.1kHz, when padding is 1, frame length is 210 bytes. After the table header there is additional information of variable length. For standard MP3 files, their length is 32 bytes, followed by compressed audio data, which will be decoded when the decoder reads here. For Constant Bit Rate (CBR) MP3 files, not all frames are the same length, and some frames may be one or more bytes longer. There is also Variable Bitrate (VBR) MP3, to minimize the length of MP3 file and ensure sound quality, compared to CBR file, except for the first frame, the rest is the same. The first frame of VBR does not contain audio data and its length is 156 bytes, which is used to store information such as standard audio frame header (4 bytes), VBR file identifier, frame number, number file byte, etc. See table 2 for the description of the structure. Table 2 Description of the first byte of the frame structure of the VBR 1-4 file The same standard sound frame header as CBR 5-40 Store the logo of the VBR file “Xing” (58 69 6E 67), the specific position of this logo depends on the adopted MPEG standard and the sound depends on the channel mode.


Free Download Mp4Gain
picture


Mp4Gain Main Window
picture


Mp4Gain Features
picture


Free Download Mp4Gain
picture

mp3 audio format, the most popular

mp3 audio format, the most popular

mp3 audio format, the most popular
mp3 audio format, the most popular

With the rapid development of file compression technology, MP3 has become the most popular music format today.

mp3 audio format, the most popular
mp3 audio format, the most popular

The encoder transforms the original sound into the frequency domain through a hybrid filter bank. Using a psychoacoustic model, it is estimated that it may be sufficient to be The perceived noise level is then quantized and converted to Huffman coding to form an MP3 bitstream. The decoder is much simpler and its task is to extract the sound signal from the encoded spectral line components through inverse quantization and inverse transformation.
2.4 Modified Discrete Cosine Transform Modified Discrete Cosine Transform (MDCT) refers to converting a set of time-domain data to frequency-domain data for time-domain variation. MDCT is an enhancement of the DCT algorithm. The first fast algorithm is the Fast Fourier Transform (FFT), but FFT has operations on complex numbers and MDCT are all operations on real numbers, which is convenient for programming. When compressing audio data, first divide the original audio data into fixed blocks, and then perform forward MDCT (Forward MDCT) to convert the value of each block into MDCT 512 coefficients. When decompressing, the reverse MDCT (Reverse MDCT) The 512 coefficients are restored to the original sound data, and the original sound data before and after are inconsistent, because redundant and irrelevant data are removed during the compression process. The FMDCT transformation formula is: k=0, 1,…, N/2-1 where N is the length of the transformation window, that is, the number of sample points per block, N=8, 16 ,… ., 1024, 2048. n0=(N/2+1)/2, X(n) is the value in the time domain, X(k) is the value in the frequency domain. If N takes 1024 points, it will become 512 frequency domain values. The IMDCT transformation formula is: 4 Modified Discrete Cosine Transform Modified Discrete Cosine Transform (MDCT) refers to converting a set of time-domain data to frequency-domain data to learn the changes in the domain. weather. MDCT is an enhancement of the DCT algorithm. The first fast algorithm is the Fast Fourier Transform (FFT), but FFT has operations on complex numbers and MDCT are all operations on real numbers, which is convenient for programming. When compressing audio data, first divide the original audio data into fixed blocks, and then perform forward MDCT (Forward MDCT) to convert the value of each block into MDCT 512 coefficients. When decompressing, the reverse MDCT (Reverse MDCT) The 512 coefficients are restored to the original sound data, and the original sound data before and after are inconsistent, because redundant and irrelevant data are removed during the compression process. The FMDCT transformation formula is: k=0, 1,…, N/2-1 where N is the length of the transformation window, that is, the number of sample points per block, N=8, 16 ,… ., 1024, 2048. n0=(N/2+1)/2, X(n) is the value in the time domain, X(k) is the value in the frequency domain. If N takes 1024 points, it will become 512 frequency domain values. The IMDCT transformation formula is: 4 Modified Discrete Cosine Transform Modified Discrete Cosine Transform (MDCT) refers to converting a set of time-domain data to frequency-domain data to learn the changes in the domain. weather. MDCT is an enhancement of the DCT algorithm. The first fast algorithm is the Fast Fourier Transform (FFT), but FFT has operations on complex numbers and MDCT are all operations on real numbers, which is convenient for programming. When compressing audio data, first divide the original audio data into fixed blocks, and then perform forward MDCT (Forward MDCT) to convert the value of each block into MDCT 512 coefficients. When decompressing, the reverse MDCT (Reverse MDCT) The 512 coefficients are restored to the original sound data, and the original sound data before and after are inconsistent, because redundant and irrelevant data are removed during the compression process. The FMDCT transformation formula is: k=0, 1,…, N/2-1 where N is the length of the transformation window, that is, the number of sample points per block, N=8, 16 ,… ., 1024, 2048. n0=(N/2+1)/2, X(n) is the value in the time domain, X(k) is the value in the frequency domain.

mp3 audio format, the most popular

mp3 audio format, the most popular

mp3 audio format
mp3 audio format

With the rapid development of file compression technology, MP3 has become the most popular music format today.

mp3 audio format
mp3 audio format

High-quality music quickly spreads to all parts of the world with the arrangement of 0 and 1, shaking people’s hearts. What is MP3? The full name of MP3 is MPEG Audio Layer 3. It is an efficient computer audio coding scheme. It converts audio files into smaller files with .MP3 extension with a higher compression ratio and basically maintains the sound quality of the file. original. MP3 is part of the ISO/MPEG standard. The ISO/MPEG standard describes audio compression using a high-performance perceptual coding scheme. This standard has been continuously updated to meet the pursuit of “high quality and small quantity”, and now has formed MPEG Layer 1, Layer 2. Layer 3 three audio encoding and decoding schemes. The compression rate of MPEG Layer 3 can reach from 1:10 to 1:12. A 1M MP3 file can be played for 1 minute, while a 1 minute CD-quality WAV file (44100Hz, 16bit, 2ch, 60sec) occupies 10M of space, so Calculated, the time The playback time of a 650M MP3 disc should be more than 10 hours, while the playback time of a CD with the same capacity is about 70 minutes. The advantages of MP3 are unmatched by CD. 2 Analysis of the principle of MP3 2.1 MPEG audio standard MPEG (Moving Picture Experts Group) is a moving picture expert group under ISO, and the MPEG standard formulated by it is widely used in various multimedia. MPEG standards include video and audio standards, among which MPEG-1, MPEG-2, MPEG-2 AAC, and MPEG-4 audio standards have been developed. The MPEG-1 and MPEG-2 standards use the same family of audio codecs: Layer 1, 2 and 3. A new feature of MPEG-2 is the use of low sample rate expansion kits to reduce data traffic , and another feature is the multi-channel expansion kit, which increases the number of main channels to five. Fraunhofer IIS and AT&T released the MPEG-2 AAC (MPEG-2 Advanced Audio Coding) standard in 1997 to significantly reduce data traffic. The MDCT (Modified Discrete Cosine Transform) algorithm adopted by MPEG-2 AAC, The sampling frequency can be between 8 KHz and 96 KHz, and the number of channels can be between 1 and 48. MPEG Audio Layer 1, 2 and 3 use the same filter bank, bitstream structure, and header information, and the sample rate is either 32 KHz, 44.1 KHz, or 48 KHz. Layer 1 is designed for DCC (digital compact cassette) digital compression tape, the data rate is 384 kbps, and layer 2 has made a compromise between complexity and performance, and the data rate has been reduced to 256 kbps- 192kbps. Layer 3 was designed for low data rate from the beginning, and the data rate is 128Kbps-112Kbps. Layer 3 adds MDCT transform, which makes its frequency resolution 18 times higher than that of Layer 2. Layer 3 also uses information averaging similar to MPEG video entropy coding to reduce redundant information. The vast majority of MP3 uses the MPEG-1 standard. 2.2 The purpose of audio compression The MP3 format began in the mid-1980s, and the Fraunhofer Institute in Erlangen, Germany, was committed to high-quality, low-data-rate audio coding. Let’s look at an example: You want to sample a song you like that is about 4 minutes long, store it on a disc, and sample it in CD-quality WAV format at a sample rate of 44.1 kHz, which means receiving 44100 per second. , stereo, each sample data is 16 bits (2 bytes), so the space occupied by this song is: 44100×2 channels x2 bytes x60 seconds x4 minutes=40.4MB If you download this song from the Internet, assume the transmission speed is of 56kbps, the download time is: 40.4x106x8/56x103x60=96 minutes. Even a 1M broadband network takes more than 5 minutes. It can be seen that audio compression is especially important to reduce the storage space of audio data. 2.3 MP3 encoding and decoding MP3 audio compression involves encoding and decoding in two parts. Encoding is turning the data in a WAV file into a highly compressed bitstream, and decoding is taking the bitstream and reconstructing it into a WAV file. MP3 uses a distortion algorithm called Perceptual Audio Coding. The frequency range of sound perceived by the human ear is from 20 Hz to 20 kHz. MP3 cuts out a lot of redundant and irrelevant signals.

MP3 encoder

MP3 encoder

Mp3 Encoder
Mp3 Encoder

1. MP3 Encoder FAQ

Mp3 Encoder
Mp3 Encoder

: what is an MP3 encoder?
An MP3 encoder is a piece of software that uses the MP3 codec algorithm (compression/decompression) to create mp3 files. Most encoders only convert
a WAV file to an MP3 file, although many can convert other formats such as WMA, Real Audio, Ogg, etc.

There are only a few standalone encoders, and a lot of software also only uses 4 main encoding engines, largely due to
to Fraunhofer Gesellschaft patents and various companies helping with ISO sources. Although no company owns the license, the
Developers must pay expensive license fees no matter what proprietary MP3 encoder they use. Major MP3 encoding engines include: LAME (
non-ISO source), BladeEnc, Fraunhofer, and Real Networks’ Xing encoder.

– How does the MP3 encoder work?
The core technology under MPEG-Layer 3 is included in the MP3 encoder. The decoding process uses a series of algorithms and rules to compress audio.
The encoder also detect sounds that occur at the same time
and they try to rule out any that might be “masked” or “inaudible” by other sounds.

– What is a good MP3 encoder?
Xing is the fastest encoder in terms of speed, but the worst in quality. For smaller file sizes, Fraunhofer FastEnc
offers the best quality. LAME is a very good encoder, and one version is faster than the previous one, BladeEnc
it is the best quality for large files, but very slow.

2. Dissection of MP3 files
In addition to proficiency in using the basic features of the MP3 encoder, ordinary users do not need to know how the internal structure of the MP3 file is encoded, just like the situation when
face JPEG or DOC files. Out of morbid curiosity, here’s an X-ray view of an MP3 file:

– Box header
As mentioned above, MP3 files are made up of thousands of “frame frames”, each frame containing a part (second part) of valuable audio data.
for the decoder to reconstruct the audio data. The first part above is the box header. (Frame Header), which consists of 32-bit metadata related to the
later data, see the figure below. The MP3 header begins with an 11-bit “sync timing” block, which allows the player to seek and lock the first
legal framework available, which is useful in MP3 streaming, which can quickly move or jump ID3 from the playback source block to a normal one.
position . However, simply detecting synchronized blocks is theoretically not enough, so it is necessary to check the header.

– transmission lock
MP3 was originally designed for broadcast, and as a result it became important that the MP3 receiver could be synchronized with the signal at any part of the broadcast,
so the frame header is placed at the beginning of any frame transmission, so when an MP3 receiver “tunes” to a data stream, it picks up the
signal instantly and you can play it immediately. Interestingly, this fact makes it possible to cut MPEG files into small segments, each of which can be played independently. But unfortunately
not possible in 3-layer (MP3) files, where frames often depend on other frames, so you can’t just
Edit .

– Frames per second
Just as the movie industry has a standard for the number of frames per second in film to ensure proper viewing on any projector,
A similar standard is used in the MP3 standard, regardless of the file’s bitrate, MPEG-1 A frame in the file is 26 ms, approximately 38 fps frames per second. If the bit rate
is , the frame size is correspondingly larger, and vice versa. Also, the number of samples contained in an MP3 frame is constant, 1152 samples per frame.

The total size of any given frame can be calculated with the following formula:

FrameSize = 144 * BitRate / (SampleRate + Padding).

ENCODING PRINCIPLES OF THE MP3 FORMAT.

ENCODING PRINCIPLES OF THE MP3 FORMAT.

Mp3 Encoding

Mp3, or fully MPEG-1, 2 and 2.5 Layer 3, is one of the most popular and widespread standards for storing audio data.

MP3 ENCODING

In this article, we will not delve into the history of creation and further development, but will consider the basic principles of the standard and examples of its implementation.

The mp3 standard does not establish a specific compression algorithm to “encode” the source data, but rather describes the essence of the possible methods.

The quality of the result obtained depends on the modification of the algorithm used, embedded in any encoding program of the “codec”, and on the quality of the original audio data.

There are 3 most common modifications of the mp3 format, which differ in the compression ratio parameters of the original audio data.

Name
Modification of the rule
Data rate per second (bit rate) Possible sample rates
MPEG-1 layer 3
32 – 320 kbps 32000 Hz
44100 Hz
48000 Hz
MPEG-2 Layer 3 16 – 160 kbps 16000 Hz
22050 Hz
24000 Hz
MPEG-2.5 Layer 3 8 – up to 160 kbps 8000 Hz
11025 Hz

Processing begins with dividing the original audio signal into equal time intervals: equal frames, for example 0.05 or 0.26 seconds, after which each frame is analyzed and compressed according to general or individual parameters based on the data of the previous and next frames.

Most of the compression algorithms used are based on the perceptual characteristics of the human ear. Let’s consider the main options, which, as a rule, are applied in a complex way.

It is worth starting with the fact that, by ear, the average person is capable of perceiving a frequency range of approximately 10 Hz to 20,000 Hz. With growth, changes occur in the hearing aid and, for most, the sensitivity the higher frequency range decreases, as a result of which, in some mp3 modifications, during compression, all frequencies above 16000 hertz are cut off, which can significantly reduce the amount of information.

Audio recordings can be encoded in stereo (a surround sound effect that uses separate channels for the left and right speakers) or mono (the opposite of stereo). In mp3 format, different tracks are not recorded for each of your speakers, but information about the differences between the left and right channels.

In acoustics, there is a concept like “harmonics”, these are the frequencies of the “sounds” that sound together with the main and most prominent tone. For example, when hitting a drum, the loudest sound will be the tone and the minor, weaker, will be the harmonics.

After such a loud sound, the so-called “period of deafness” occurs, during a period of duration in which a person’s hearing practically does not respond to changes.

If in the intervals of the “deafness period”, remove all frequencies, then the errors of perception, will practically not allow to notice their absence, because of this, during compression, the weakest harmonics are cut off, located close to the most sounds. strong: tones.

A method is used to replace the near peak values ​​of the signal “peaks” (in terms of volume) with an average value.

There is a concept as bit rate: this is a value that characterizes the number of transmitted bits of information “units” during a period of time, usually one second.
The higher the bit rate, the better the audio detail will be, as long as the original, uncompressed audio data is of high quality.

As you can guess, digital formats consist of certain code sequences, in other words of sequences 0 and 1.
To save space, frequent joins within a file are assigned unique identifiers that replace long sequences.

Thanks to such complex influences, it is possible to compress the original audio signal into one of the popular formats with loss of quality – the mp3 format.

Various experiments have been carried out many times in order to reveal how significant the differences are before and after compression in mp3. As tests have shown, differences, some similar moments were not always possible, quickly and to distinguish, even when reproduced on equipment with higher fidelity.

For those who have never had the opportunity to directly compare the original and compressed audio recording, in most cases it will take some time or even find obvious differences.

MP3 ENCODING

MP3 ENCODING

Mp3 encoding

The first step in encoding by the user is to specify a bit rate. This indicates the quality and at the same time the storage requirement of an MP3 file.

MP3 encoding

COMPRESSION RATES

With most recording programs, the quality of an MP3 file can be freely selected before recording begins. According to the Fraunhofer Institute, the CD quality of an MP3 file is a bit rate of 112 to 128 kbit per second, other measurements put CD quality at up to 160 kbit per second. However, the most used and sufficient for most listeners is 128 kbit.

In comparison, a corresponding CD quality for Layer 1 is 384 kbit / s and 256 kbit / s for Layer 2. A wave file works with a 1.4 Mbit / s bit rate and therefore works with roughly the same space requirements. as a CD audio track (CDA).

74 or 80 minutes of music can be put on a CD (depending on the size of the sound carrier), in MP3 format with a bit rate of 128 kbit / s, 11.5 or 12.4 hours would be possible.

PSYCHOACOUSTICS

MP3 audio compression relies on filtering out unnecessary information. Psychoacoustics is a science that deals with the perception of sound by the human ear.

Eg: You are in a disco. Loud music blasts through huge speakers and you try to talk to each other. This is almost impossible unless you yell. In acoustics, this is called masking. To eliminate masking, the sound level of speech should be raised to such an extent that the interfering signal (in this case music) no longer covers it.

Processes like this belong to the fundamental areas of psychoacoustics.

Tones below this threshold are not heard and therefore become noise during MP3 recording (skipped).

The overlays work as follows: you have, for example (picture 2) a tone with 1 kHz (1) and another tone with 1.1 kHz, which is approximately 18 dB lower (2). The second shade is completely superimposed on the first. This also works for other weaker tones (see Fig. 2). Another tone with a frequency of 2 kHz, which is also 18 dB quieter than the first, would not overlap because it is just outside the threshold of the first tone.

Noise can be another compression option for MP3 recording. The fact that when a sound is digitized it cannot be sampled at an infinite frequency, a noise imperceptible to the human ear (quantization noise) is generated. It is used as a model for the MPEG audio layer and thus increases the noise around a tone. Above all, loud and short tones mask a certain range in the frequency range before and after themselves where the weakest signals would not be audible. With MP3 encoding, the noise level increases in this area, as if digitized at a lower resolution.

There is also masking in the temporal area: hearing needs a so-called “recovery time” for loud and quiet noises until it is fully functional again. This is especially noticeable with strong, short, and rapidly rising tones. After a delay of about 5 ms, the hearing threshold drops again and after about 200 ms it reaches the normal level, the so-called resting hearing threshold. This effect is called post-masking. The effect of pre-masking is less important, but even more impressive: it is based on the fact that the brain processes loud sounds more quickly than soft ones. To some extent, the strong impulse outweighs the silent one on the way to the brain. This results in a pre-masking time of up to 20 ms.

The above psychoacoustic algorithm is used in the following steps:
– Audio information is divided into subbands
– Subbands are reduced
– 16-bit samples are generated
– Samples are compressed
– Compressed samples are combined into blocks
– Coding according to Huffmann Procedure
: summary in tables

DIVIDED INTO SUBBANDS

Depending on the frequency of the acoustic information, it is divided into 32 subbands. The bands are of different sizes due to adaptation to the human ear according to a psychoacoustic model.

The division is done with the help of a polyphase filter. This means that the samples are decimated and filtered simultaneously.

In layers 1 and 2, the bands were the same size with a bandwidth of 625 Hz each. The reason for this division is to provide the algorithm with a better target.

SUBBAND ​​REDUCTION

The MP3 encoder now examines each of the subbands according to the psychoacoustic model for expendable frequencies. Here, the masking threshold is determined, then the subbands whose level is below this masking function are removed. Another reason for dropping an entire sub-band could be that it is inaudible due to the pitch, similar to a dog’s whistle.

CONVERSION INTO 16-BIT SAMPLES

The frequency bands are sampled and converted to 16-bit samples. Tones are broken down into digital signals and further processed as numerical values. The sample rate determines the length of the sample intervals. However, neither the measurement of the amplitude nor the size of the sampling intervals can be infinitely precise. For this reason, with analog-digital conversion, a value is rounded between two sample points. This results in rounding errors that are noted in what is known as quantization noise. This can be kept inaudible using the highest possible resolution: with 8-bit, a maximum of 256 levels can be displayed, with 12-bit and 4096 and with 16-bit 65536 individual steps, so that noise is not heard.

However, some samples are also digitized with a lower sample rate. In the eighth subband, for example, there is a tone with 1 kHz and 60 dB. The MPEG audio encoder now calculates the masking threshold and recognizes that it is 36dB lower. The acceptable signal-to-noise ratio here is 24 dB, which corresponds to a 4-bit resolution, since the two values ​​are directly related. Leaving one bit out of resolution increases the noise level by 6dB. Since an audio CD is generally digitized with 16 bits, considerable data reduction can be applied here.

SAMPLE COMPRESSION

The next step is to compress the samples further. However, this process no longer has anything to do with the original shades. From here on, compression is only data-driven.

Each sample consists of 16 bits, but not all of them are absolutely necessary to represent a level. For example, leading zeros can be omitted. If, for example, the value 0000011101010101 is obtained for a sample, the algorithm truncates the result to 11101010101. To reconstruct the original 16 bits from this information, the decoder needs two pieces of information: the scale factor and the bit allocation. The scale factor indicates where the remaining bits of the sample were in their original state. The bit mapping contains the information about how many bits are left in the sample, since you can no longer calculate with a fixed 16-bit number. However, if you were to store these values ​​individually for each sample, you wouldn’t gain much,

GROUPING THE SAMPLES

The 16-bit samples that were just created are now combined into blocks. There are two different block lengths for this purpose: the short blocks with twelve samples and the long blocks with 36 samples.

Long blocks are used for low frequencies. However, long blocks would not allow sufficient resolution at higher frequencies; short blocks are used here. In the so-called mixed block mode, long blocks are used for the two frequency bands with the lowest frequencies. For the remaining 30 frequency bands, it is the turn of the short blocks. This mode allows better frequency resolution in the low frequencies without paying tribute to the sampling frequency in the high frequencies.

HUFFMANN CODING

The last step in MP3 compression is Huffmann encoding. This algorithm is also used, for example, in packaging programs such as WinZip. The frequency of certain values ​​is important here. However, the subbands are organized in advance. Subbands with lower frequencies tend to contain significantly more values ​​than those with high frequencies. The subbands are divided into three groups according to their frequency. Each area has its own Huffmann tree (Fig. 3) to achieve the optimal compression factor.

As a first step, the encoder excludes high frequencies; encoding is not necessary here, as its size can be derived from those of the other two regions. The mid-frequency range is treated as is, and the low frequencies are again divided into three regions, each of which is assigned its own Huffmann tree. The appearance of a Huffmann tree is stored in the MP3 file.

The structure of a Huffmann tree works as follows: frequently occurring values ​​are given a short sequence of bits, while rare values ​​are given a long one, so the algorithm first determines the distribution of values ​​within the data to be compressed.

To determine what is known as the Huffman tree, you start with the two rarest values. They are assigned a “0” or a “1”. The two values ​​are summarized, in the order that they are now represented by the sum of their frequency. The same is true for the next two rarer values. This process ends when only one value remains. The result of this procedure is a tree structure. The encoding is based on this structure. Each branch on the left receives a 0, each branch on the right is identified by a “1”. In our little example, the least common would be

Value 4 represented by the sequence of bits 010. The most common value 6, on the other hand, is assigned a simple 1.

FRAMEWORK SUMMARY

The result of the above compression is summarized in so-called frames. Each of these frames contains 1152 samples (32 subbands x 36 samples). A frame consists of a header, a checksum check, the actual audio data, and in certain circumstances a so-called bit repository. Such a deposit arises when the samples within the frame can be compressed in such a way that the full theoretical number of bits in a frame is not required. The encoder can fall back on these buckets if the available bits are insufficient for a subsequent frame. A distinction must be made between two terms: frame size and frame length.

The size of the frame is determined by the number of samples and is constant within a layer. In Layer 1 format, this is always 384 samples per frame, in Layers 2 and 3 1152 per frame. However, the length of the frame may differ at Layer 3 due to the change in bit rate or the pool of unfilled bits. The frame also contains the aforementioned information about the scale factor and bit allocation to be able to reconstruct all the samples again.

A file header, as it is known from other file formats, does not exist in an MP3 file. In the case of an image file, a header would contain information about the entire image (e.g. size, color depth, resolution

MP3 COMPRESSION

MP3 COMPRESSION

To achieve such a dramatic reduction in the number of bits required to transmit an MP audio signal, use different techniques. These techniques include those based on perceptual coding and others such as byte reservation, stereo assembly or Huffman codes. Percentage coding consists of removing all the information that goes into the audio signal that the human ear is not capable of detecting. We will now describe them:

PERCEPTUAL CODING

Minimum hearing threshold The ear’s minimum hearing threshold is the power below which a tone at a given frequency is not capable of being detected by the ear. This threshold is non-linear. As we see in the figure, which represents the Fletcher and Mundson law, the frequencies in which we hear best are those between 2 and 5 Khz. Therefore frequencies outside that band are not totally essential since they will hardly be perceived. Therefore it is possible to remove the content of the audio signal outside these frequencies.

As we can see in the drawing, the range in which a lower power is needed for the tone to be heard is between 2 and 4 Khz.

The masking effect This effect consists in that, when an audio signal has a tone at a given frequency, it produces a masking effect at the frequencies close to it, so that if at these nearby frequencies the signal does not exceed a certain power threshold cannot be heard and therefore it is not necessary to encode them. The form that this power threshold will take according to the position of the tone or the masking tones is what is called the psychoacoustic model, which as the name itself indicates is a perception model that tries to emulate the perception of the human ear.

In this graph we can see how if we put a tone at 1 Khz of 60 dB (masking tone) and then we put another tone at, for example 1.1 Khz and we vary the frequency of this, it is not possible to detect the presence of this second tone until its power exceeds the threshold presented in the figure.

In this case we see various masking tones and the resulting new hearing thresholds. In MP3, what is done is to divide the spectrum to be transmitted (that is, between 2 and 5 Khz) into frequency subbands, so that the power of the subband is evaluated and the masking threshold is created in the nearby subbands. Nearby subbands that exceed that power threshold are coded and those that do not exceed it are not coded.

Furthermore, the masking is not only in appearance but also in time as we can see in the figure.

The byte reserve: Often, some passages of a musical piece cannot be encoded at the same rate without altering the quality of the music. MP · then uses a small byte reservation that acts as a buffer using the capacity of passages that can be encoded at a lower rate in the given stream.
The stereo assembly In the case of a stereo signal, the MP3 format can use a few more tools to further compress the data.
Intensity stereo (IS) The human ear is not able to locate with complete certainty the spatial origin of sounds for very high or very low frequencies. This technique takes advantage of this, recording some frequencies as a monophonic signal, so that a minimum of spatial content is subtracted from the sound.
Mid / Side (M / S) Stereo When the left and right channels are similar then a middle channel (L + R) and a side channel (LR) are created, which are encoded instead of encoding the left channel on one side and the right for another. In this way it is possible to reduce the transmitted data using fewer bits for the lateral channel. Then during playback the MP3 decoder will reconstruct the left and right channels.

Huffman Coding: This coding technique is used at the end of the whole process. It works by creating variable-length codes, so that the symbols that appear in the bitstream most likely have shorter codes. The translation between symbols and codes is done using a table. Each code has a unique prefix so that the codes can be decoded correctly despite their variable length. This type of coding allows on average to reduce by 20% the amount of data to be transmitted. It is an ideal complement to perceptual coding since, during great polyphonies, perceptual coding is very efficient since many sounds are masked, but nevertheless little information is identical and Huffman’s algorithm becomes inefficient. During pure sounds there are few masking effects, but Huffman encoding is very efficient since digitized sound contains many repeating bytes.