Sound data and working with it
Sound is vibration of the air. The computer turns it into an electrical signal with a microphone, measures it many times per second and stores each measurement as a number; this is called sampling. The number of measurements per second is the sampling rate (for example 44100 Hz on an audio CD), and the number of bits for one measurement is the bit depth (16 bits). Stereo sound has two channels (left and right), so the size is twice as big. Uncompressed size = rate × bit depth × channels × seconds (in bits); divide by 8 to get bytes. For example, 16 bits = 2 bytes, so a 10-second stereo recording is 44100·2·2·10 = 1764000 bytes. Files: WAV is usually uncompressed and large; FLAC reduces the size but loses nothing; MP3 and AAC use lossy compression and are about 8–10 times smaller. Video is quickly changing pictures plus sound; MP4 (H.264) and WebM are widely used. HTML5 has the <audio> and <video> elements: the controls attribute shows the control buttons, <source> offers several formats (the browser picks one), <track> adds captions, and poster is a picture shown before the video starts. So as not to annoy the user, sound should not start by itself (do not use autoplay), and captions should be given. Changing a file extension does not change the format: renaming .avi to .mp4 does not convert it; a special program is needed. Other people's music and video are protected by copyright; place only files you recorded yourself or ones with a free licence.
A phone call sounds a little “thin”, while well-recorded music sounds full and rich. The difference is that the more often and the more accurately a sound is measured, the more fully it is kept. But a fuller recording takes more space, so a compromise between the two is chosen.
Radio journalists, sound engineers who record music and telephone technicians strike a balance between quality and size.
On squared paper draw a wavy line and mark its height first at every column and then at every fourth column, joining the dots. Which is closer to the original line?
1<!DOCTYPE html> 2<html lang="uz"> 3<head> 4 <meta charset="utf-8"> 5 <title>Ovoz va video</title> 6</head> 7<body> 8 <h1>Maktab radiosi</h1> 9 <audio controls src="salom.mp3">Brauzer audio elementini qo‘llamaydi.</audio> 10 <video controls width="320" poster="muqova.jpg"> 11 <source src="lavha.mp4" type="video/mp4"> 12 <source src="lavha.webm" type="video/webm"> 13 <track kind="captions" src="lavha.vtt" srclang="uz" label="O‘zbekcha"> 14 Brauzer video elementini qo‘llamaydi. 15 </video> 16</body> 17</html>
| Format | Calculation | One minute, bytes |
|---|---|---|
| MP3 128 kbit/s | 128000·60/8 | 960000 |
| CD quality | 44100·16·2·60/8 | 10584000 |
Record 10 seconds of sound with your phone, save it in two formats (for example WAV and MP3) and compare the sizes. Compare the difference with your own calculation.