
Lossless audio compression

Sound is a simple wave and digitized sound is a digital representation of that wave.

This is accomplished by storing the level of the analog signal several times in one second. For example, on an ordinary CD, a signal is stored 44100 times per second. Since the CD works with stereo, we store the signal for the left and right speakers in parallel. 16-bit numbers are used for each measurement. So it’s easy to calculate that one second of polling takes 2 × 2 × 44100 = 176,400 bytes. Lossless audio compression is a set of transformations that efficiently compress the audio data with the possibility of its complete recovery. Like any lossless compression, audio data compression exploits some characteristic of the data. In this case, these are:
Knowing the limits of the samples: We know how many bits or bytes are allocated per sample sample and how many audio channels are in the sample.
Low derivative: In other words, the values of the adjacent samples differ little.
Low second derivative: the values of the three adjacent samples are close to a linear function.
Closeness of the left and right channels: The signal levels in the left and right speakers are usually close.
Rice’s algorithm
The idea behind audio compression is to represent the numbers corresponding to the stream as small as possible, removing any data correlation beforehand. You can then write the encoded data stream to disk. One of the most efficient ways is Rice encoding. Smaller numbers are preferred because their binary representation is shorter. For example, you need to encode the following row: Base in base 10:10, 14, 15, 46 OR the same row in binary form Base 2: 1010, 1110, 1111, 101110 Now if you want to represent this as a string, where 32 bits are reserved for each number for the range of all possible values, it will be ineffective, since 128 bits are needed. However, there is a more effective method. The best solution would be to simply write the binary numbers 1010, 1110, 1111, 101110 without commas, obtaining a series like 101011101111101110. The problem is that afterwards there is no way to know the limits of each number. As a general rule, the Rice algorithm is used as a solution to this problem. Rice encoding is a way of representing small numbers on a single line while still being able to distinguish them. Note: the smaller the numbers, the more efficient the algorithm will be, so you need to deal with this initially. At some stage in encoding, the data is represented as a number n. When encoded, it is added to the right of the string of already encoded numbers in such a way that the reverse process is possible. The basic idea is to represent the number n as n = q ∗ 2 k + r {\ displaystyle n = q * 2 ^ {k} + r} so that 0



