Skip to main content

Audio Formats.

We have completed our first step towards building a music player by developing a way to store the music files locally on the sd card. Now we will shift our focus towards understanding the way in which music is stored. The first audio was stored as analogue signal transcribe mechanically on a paper or glass but since then we have rapidly developed various other more efficient ways to store an audio signal. The digital formats revolutionized the whole industry as it was easier to store, process as well as replicate. Currently, we deal with various digital formats such as AIFF, AAC, MPEG standard etc. The MP3 is the MPEG-1 Audio layer 3 and is one of the most recognized audio file formats as it uses lossy data compression which drastically decreases the file sizes and is one of the reasons which caused the boom in the music industry in the 1990's. The format itself is quite complex as it uses advanced compression techniques such as the Huffman coding and so we will begin our discussion with the WAV format which will make our work easier along with providing the right amount of knowledge regarding file formats.

Consider a signal with different values at different intervals. If we know the maximum amplitude of the signal then we can divide the range of different amplitudes into discrete values. For eg, Consider a signal lying between 0 volts to 5 volts. If we divide the range(5-0) volts into 100 levels and store the value at any given moment as one of the numbers in between 1-100, then we can successfully store an analogue signal as binary numbers. This technique is known as Analog to Digital Conversion and sampling of the signal is done as to get the values at different times.




So if provide an analogue audio file as an input to the ADC we will be able to get the corresponding digital values at a particular frequency i.e if we have a sampling frequency of 'n' Hz then we will get 'n' different values of the audio in one second. This is known as a RAW file as we have the discrete values of an analogue signal at a particular frequency but it is uncompressed or unaltered. We can use this to play the music using our MCU as this is a digital audio format but we won't be able to do this without knowing the sampling frequency and the sampling resolution. For these pieces of information, we use the WAV file format which contains the RAW data along with some metadata about the music file such as its name, frequency, bit resolution, number of channels etc.
This time we will be storing our music file as a WAV file in the sd card as they are easy to manipulate. These files have one major disadvantage, they are very huge in size and so in the upcoming posts we will shift to MP3 and develop a complete music player.

WAVE stands for Waveform Audio File Format and is commonly written as WAV due to its file extension. It is a Microsoft and IBM audio file format standard for storing audio bitstreams on PC.
A typical WAVE file contains a 44 bytes Header followed by the data segment.



The data segment contains the bytes which are sampled at the frequency provided in the header. 44.1 kHz is a common sampling rate. For testing purpose, we can download any .wav file and open it using notepad and we will be able to see the above data very clearly. The information which is very much needed is the file size, Number of channels, Sample rate and the Bits per sample. We need to write a software to parse the header and extract the above info along with marking the start of the data segment by using the "data" chunk header.






Comments

Popular posts from this blog

Let's Build a Music Player!

Digital Music Player's are one of the many sensational devices that were developed in the 20th century. They have been around for a while now and have become a part of our life. In the last few years, they have been integrated within Smart Phones and hence, have reached the masses. Now, Let us try to dive into knowing how these devices work and I guarantee that we all would be fascinated by the kind of engineering which goes into making these magic boxes. There are various topics which must be covered in order to build our own music player and so there will be several blogs to build a SOUND foundation. Now let us make a list of the required components and then we will walk through each of them in the upcoming blogs. There are 3 basic parts which are required to build a device which can output Audio:- Storage Medium. Micro-controller. Audio Output device. We will store the required music file onto a storage medium as the onboard memory on a microcontroller is low...

SD-CARD

This Post marks the beginning of our quest to develop a simple Music player. SD stands for Secure digital and these small devices have been around for a while now. They contain flash memory and a memory controller which is given instruction by the main MCU. So our main objective here is to understand how sd cards work and how to interface them with a microcontroller. As to understand the working of SD card we need to dive into the world of transistors and bits! The Sd card contains solid-state memory also known as the flash memory which is a type of EEPROM i.e  Electronically Erasable Programmable Read Only Memory .  Flash memory stores information in an array of memory cells made from  floating-gate transistors . These transistors are used in different topologies as to store each bit. We will not program each bit individually as it will be time-consuming as well as an inefficient way to store the data. As to move to a higher level of abstraction, we need a way to ...

Automated Outdoor Lighting

This Project enables a person to make any Outdoor Lighting Automated i.e to switch On/Off according to the sunlight outside. If it is dark outside then the light will turn On and if it is daytime then it will automatically switch Off. This can be very useful for all Outdoor Lighting of various commercial buildings as well as for residential buildings. This can also be implemented in Vehicles which will automatically turn their lights On.  Our aim can be achieved by designing a proper transistor circuit and using a relay with it to control the high voltage network. T he Requirements Are: 1:- Bipolar Transistor(Bc 547) 2:-5/6v Spdt Relay 3:-Resistors(Around 4.5k And 3k Ohm) 4:-Light Dependent Resistor 5:-5v Power Supply 6:-Pcb For Soldering Things Together 7:-Multimeter          CIRCUIT AND EXPLANATION The project involves the use of a transistor as a switch to make the outdoor light on/off. As we know that transistor can be used in three diffe...