In order to fulfill the basic functions of our service, the user hereby agrees to allow Xiaomi to collect, process and use personal information which shall include but not be limited to written threads, pictures, comments, replies in the Mi Community, and relevant data types listed in Xiaomi's Private Policy. By selecting "Agree", you agree to Xiaomi's Private Policy and Content Policy .
Agree

Mi Max 3

[Discussion] [How It Works #18] What is MP3, And how it work!

2019-09-25 10:04:14
1640 65


Hello Dear MIUI Fan's!
Today you'll know more about MP3 File format, how comress this file and other information about it. Many of us remember CD players and CDs. So on such a disk could fit a maximum of 20-23 songs). And with the advent of MP3 on one disc, you can record about 100. Today's you know how encoded MP3 file.



About CD and CD recording!
The question arises:
  • How can I compress an audio file while leaving the quality at the same level?
  • How does this mp3 format work?
  • And if this is all the same deception, then what exactly does it consist of?

But in order to understand how ingenious the mp3 thing is, you need to figure out how a regular CD file is encoded. This is done in the simplest way - it records the level of the analog signal at small intervals, on a CD it is done 44,100 times per second!

And in each measurement, the signal level is encoded with a 16-bit number, that is, ~65,000 gradations are obtained.
And if the stereo recording is two channels in parallel, it is very easy to calculate that one second of such audio will occupy 1411 kibits (44,100x16x2). But mp3 can manage with a data stream (bitrate) of 128 kibits in one second, and this is 11 times less than on a CD.

You ask. What kind of magic?  How is it possible to compress the audio recording? You can’t just skip 10 reports! And now there are compression formats and abruptly mp3 (WAV,OGG,ACC,WMA etc).

But they use exactly the same principles as MP3. So let's look at the most iconic of them!
It turns out that mp3 information is recorded in a completely different way and the basis of everything is the so-called Fourier transform.
What is this? We know that sound is a wave. Let's look at an example of some kind of audio signal, it turns out that this is some kind of ugly wave!


But this is not a record so scary it is actually  Beethoven)). Sound in itself is a mixture of waves with different frequencies, overlapping each other they led to this form.


The Fourier transform does the following: it allows you to understand what frequencies a given audio signal consists of, and with what intensity each of them sounds.
By the way, this is exactly how Shazam works: it decomposes the recorded sound into frequencies, selects specific notes (special sounds) and compares it with its database.
Of course, when an mp3 file is encoded, it is first broken into small pieces (the so-called frames, 0,0026 sec) Fourier transform is performed on each of them, and the fun begins! The fact is that our hearing is not perfect, it is inherent in everyone!
For example, with age, sensitivity to high frequencies decreases - therefore, in mp3 it immediately cuts off anything above 16,000 hertz.
Link for 16000 Hertz sound
Cruel! I agree! but you yourself listen to these 16,000 hertz (everyone who heard it means you are less than 30-35 years old, well, if you have not heard more than 30-35 years old, respectively).

Thus it turns out to slightly reduce the file size. But the greatest compression can be achieved using the so-called masking effect.
It turns out that if at some frequency the signal is very loud, it can simply drown out the neighboring frequencies and frequencies that are multiples of it, the so-called harmonics.
It turns out that we can simply remove part of the sound signal and no one will notice it! There is another type of disguise  (Time masking - 0.05 sec)- it turns out that after a very loud signal, a short period of deafness occurs.
Therefore, if there is a loud sound, then after it the entire signal can be removed and no one will notice it either! Temporary deafness may occur even before a loud sound (motorcycle sound). This is due to the features of the processing of audio signals in our brain, and it is very easy to check! This is the use of the so-called psycho-acoustic model in life, which takes into account the imperfection of our hearing.

But there are also tricks, for example, when recording a stereo file, not the left and right channels are recorded separately, but the sum of the channels divided in half and the difference of the channels. Music tracks are mixed so that most of the instruments sound the same in both channels, that is, there are not many details in the channel difference. Therefore, it can be encoded more roughly, which further reduces the file size. But that's not all! Now the most important thing. Look! on the one hand, we deleted information that we don’t need, but in fact we just replaced it with the same characters, for example:
zero "0"



But they did stay in the file, so you still need to encode them so that they take up as little space as possible.

And this is done using the so-called Huffman code.
Such compression does not lead to additional losses and it works like this: for each character in the file (well, more precisely in the frame), some code is assigned: moreover, if the character is found often, the code is short, and if the character is rare, then it is long.


And it works like this: if we cut out quite a lot from the file and we have many zeros, then we can encode them with a very small number of bits.


Therefore, the file size will be small! And at the last stage, the Fourier transform coefficients (well, those that remain) are written into the frame, and they are all glued together and a finished file is formed. Well, the playback is in the reverse order. As you understand, when encoding mp3 there are irreversible losses, because we delete a lot of  things. It turns out that we are very much deceived, but this is only because we ourselves allow it! After all, our perception of sound is not perfect.
And yes, we can only distinguish 9% of the audio information. Well and good! After all, on the other hand, we 9% is enough to perceive the whole sound picture! And precisely because of this imperfection, we can easily hear our interlocutors in a noisy crowd, we don’t stall at concerts, and we can download a lot of music from the Internet without wasting precious traffic.
That's the whole algorithm for compressing and encoding an MP3 file. I hope it was interesting.

Thanks to Administrator and SMod and Mod!

Related thread:

Rate

Number of participants 6 Experience +67 Pack Reason

View Rating Log

2019-09-25 10:04:14
Favorites32 RateRate

Resource Team

iMKajal | from MI 8

#1

Informative Thread!
2019-09-25 10:42:57

Semi Pro Bunny

Scorpen | from Redmi Note 7S

#2

informative
2019-09-25 11:04:49

Pro Bunny

1772698295 | from MI MAX

#3

Congrats, easily explained
2019-09-25 12:15:58

Master Bunny

vespaman | from app

#4

thanks to you. i like this kind of topics. nice to allow everyone to understand easily this kind of things.
2019-09-25 12:30:10

Moderator

BeingBishal | from MI 9 SE

#5

Thanks for information!
2019-09-25 12:52:49

Master Bunny

Mimsey | from Redmi 4X

#6

Superbly explanied!!
2019-09-25 13:32:55

Grand Master Bunny

1860bodo | from Redmi Note 5

#7

thanks for information
2019-09-25 13:55:25

Pro Bunny

Yohaness | from MI 9

#8

thanks it's useful
2019-09-25 14:35:36

Pro Bunny

bob72gar | from Redmi 5 Plus

#9

Nice thread, thank you for sharing!
2019-09-25 14:37:56
01010101010101..is my 1st lessons...Binary code..... struggling with this matter...hahahaha..
2019-09-25 14:51:20
please sign in to reply.
Sign In Sign Up

TomHenson

Süper moderatör

  • Followers

    791

  • Threads

    134

  • Replies

    735

  • Points

    65427

Check-in 3 jours
Check-in 7 jours
Check-in 21 jours
Check-in 40 jours
Check-in 70 jours
Newbie Member
100 Коментарів
100 Тем
New Home
10k Mi Fans
Redmi Note 7
Cast Away
20K Mi Fans
Mi Love U & I
Bunny Winner
20K Mi Fans
Best Mi
Android Q
50K Mi Fans
Mobile Photography Lover
70K Mi Fans
Challenger
Eid ul-Fitr Mubarak
Brain Teaser
100K Mi Fans
Selfie Day
Mi 9T
Global Fans
My Country My Pride
Like
Check in
Reply
Favorites
Post
Profile Medal
MIUI 9th Birthday
Global Community
500
Redmi 7A
better together slogan
Global Community
games discuss
Mid-Autumn Festival
200K Mi Fans

Read moreGet new
Copyright©2016-2019 Xiaomi.com, All Rights Reserved
Content Policy
Quick Reply To Top Return to the list