Menu English Ukrainian russian Home

Free technical library for hobbyists and professionals Free technical library


ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING
Free library / Schemes of radio-electronic and electrical devices

MP3 and Opus audio player. Encyclopedia of radio electronics and electrical engineering

Free technical library

Encyclopedia of radio electronics and electrical engineering / Audio equipment

Comments on the article Comments on the article

This article describes a homemade portable player for music files of common formats from a microSD memory card. It is assembled on the STM32F407VGT6 microcontroller in a case from a NOKIA 1100 cell phone.

The player scheme is shown in fig. 1. It makes maximum use of the electronic components available on the STM32F4DISCOVERY development board. These include the STM32F407VGT6 (DD1) microcontroller, LD3985M25R (DA1) and LD3985M33R (DA3) integrated voltage regulators, CS43L22 (DD2) codec, as well as the necessary passive components. From the cell phone NOKIA 1100, in addition to the case and the battery, a connector for connecting XS3 headphones, a front panel with an LCD HG1, membranes for buttons SB1-SB17 formed by concentric contact pads on a printed circuit board, and a connector for connecting a G1 battery were used. In addition, the player's board contains a holder for a microSD memory card TFC-WPCE-08 (XS1), a group of contact pads for connecting the Xp1 programmer, a miniUSB-B 5075BMR-05-SM (XS2) connector.

MP3 and Opus audio player
Rice. 1. Player layout (click to enlarge)

Diode assemblies VD1, VD4, VD5, VD6 are used to protect against electrostatic discharge circuits connected to connectors XS2 and XS3. The remaining connectors are located inside the battery compartment and do not need protection. Chip (DA2) is a G1 lithium-ion battery charge controller with a maximum voltage of 4,2 V. Resistor R9 reduces the voltage drop on this chip during charging, causing it to heat up. Resistor R10 set the maximum charging current Isal.max according to formula Iper ap.max = 1000/R10. With resistance R10 set in kiloohms, the value of the charging current is obtained in milliamps.

It is recommended to charge a lithium-ion battery with a current of no more than 1C, where C is the battery capacity. The capacity of the used BL-5C battery is about 1000 mAh, the maximum allowable charging current for the LTC4054ES5-4.2 chip is 800 mA. Since charging is carried out from the USB bus, its load capacity (500 mA) must also be taken into account. Thus, the recommended value of R10 is 2 kOhm. In addition, by measuring the voltage across R10, you can determine the current value of the battery charging current using the formula Izar= 1000 UR10/ R10 (current - in milliamps, voltage - in volts, resistance - in kiloohms).

When the XS2 connector is connected to the USB bus, the field-effect transistor VT1 disconnects the battery G1 from the player's power circuit. A voltage of 5 V from pin 1 of connector XS2 opens transistor VT5, the gate voltage of transistor VT3 becomes negative relative to its source. Transistor VT3 opens, including the player.

When there is no voltage on pin 1 of connector XS2, the gate potential of transistor VT3 is close to its source potential and the transistor is closed.

Pressing the SB1 button also opens the transistor VT3, the microcontroller starts working and checks the status of this button every 10 ms. If it is held down for more than 2 seconds, the microcontroller will set a high voltage level at the base of transistor VT2, opening it and keeping transistor VT3 open. After that, the player goes into working condition, and the button can be released. Turn off the player by pressing and holding the SB1 button again.

After switching on, the microcontroller initializes the HG1 LCD and the microSD card inserted into the XS1 holder, checks for the presence of the player.ini configuration file in the root directory of the card (FAT12, FAT16, FAT32 file systems are supported). This is a regular ini file, which is a set of "key - value" lines. It stores information about the audio file selected for playback at the time the player was last turned off, the position in it and the volume set. The program tries to restore this state. In case of failure (for example, if the card has been replaced), the first audio file (with the extension .mp3 or .opus) on the card is searched. The search starts from the root directory, the files are searched in the order in which they are listed in the file allocation table on the map.

During playback, the MainThread function of the current decoder is periodically called, which performs reading from the card as needed (each codec is responsible for buffering itself, since the formats of the audio packet containers for .opus and .mp3 are different) and decoding. The need to perform these operations is determined by the fullness of the circular AudioBuffer buffer, from which the audio codec asynchronously reads information. Upon completion of decoding the current audio file, the next one is searched according to the principle described above. If file system traversal is completed, playback stops.

The player interacts with the user using a graphic monochrome HG1 LCD with a resolution of 96x65 px and buttons SB 1 -SB 17. A software simulation of the text display mode is used with the screen split into eight lines of 8 px height. The remaining 1px horizontal bar at the bottom of the screen is used to visually display the current position in the file during playback.

The first line from the top displays (from left to right) battery voltage, player status, volume. The status is characterized by the characters "0" - playback, "-" - pause, "<<" or ">>" - fast rewind or fast forward, respectively, within the file. The symbol in the form of a rectangle means an error in the communication of the DD1 and DD2 microcircuits via the I interface2C.

Lines 2-6 show the full path to the audio file being played. Line 8 displays the current playback time on the left, and the duration of the audio file on the right.

The SB1 button switches between playback and pause modes, the SB3 button increases the volume, and the SB5 button decreases the volume, the SB4 button turns on, and the keypad lock is turned off with the SB15 button. When the keypad is locked, "Locked" is displayed in the center of line 7 of the display. Pressing the SB6 button leads to the transition to the playback of the previous file, and the SB8 button - the next. Pressing and holding these buttons for more than a second puts the player into fast-forward mode, rewinding or forwarding, respectively. Pressing the SB9 or SB11 button loads the first and last files of the current directory for playback, respectively.

Connector XS3 - available in the housing used for connecting a headset. The headset itself has a jack for a standard audio plug with a diameter of 3,5 mm, to which headphones are connected. The headset also provides a button that, when pressed, connects the BTN and GND circuits, and the resistance between the contacts of the released button is about a kiloohm. In the player, the BTN line is connected to the 3,3 V circuit through a resistor R21, therefore, by measuring the voltage on this line, one can judge both the presence of a connected headset and the state of its button. The function of the headset button is similar to the function of the SB1 player button - you can switch it from playback to pause mode, and vice versa, and also turn it off. However, you can not turn on the player using it. When the keyboard is locked, the headset button remains active.

The XS2 connector takes the place of the LED flashlight lens in the phone. When a high logic level is detected at the PA1 input of the microcontroller connected to pin 9 of this connector, the program starts to display the battery charging current in amperes in the upper right corner of the display. In addition, this event automatically turns on the player if it was turned off. By default, after that, the player works in normal playback mode, which allows you to listen to music and charge the battery at the same time.

When you press the SB13 button, the program saves the player's state in the player.ini file and configures the USB microcontroller module to work in MSC (Mass Storage Class) mode. In this mode, the computer recognizes the player connected to the USB connector as a removable storage device, the contents of which match those recorded on the microSD card inserted into the player. Information is exchanged with the computer only in Full Speed ​​mode with a bandwidth of no more than 12 Mbps. The display still shows the current value of the charging current, in line 3 - the inscription "USB Disk", in lines 4 and 5 - respectively, the speed of reading and writing. By pressing the SB12 button, the device returns to the player mode.

The drawing of the printed circuit board of the player is shown in fig. 2. Its dimensions and shape are identical to the board of the NOKIA 1100 cell phone, in which case it is placed (Fig. 3). The board must be manufactured according to the technology with metallized holes, otherwise it is necessary to insert and solder pieces of tinned wire on both sides into all vias (with pads on both sides of the board) and solder them on both sides. The location of the parts on the board is shown in fig. 4 in 2:1 scale. It also shows masks made of heat-resistant insulating varnish, which must be used to protect the printed conductors. If the masks are not applied, then it is necessary to isolate at least the areas where the conductors approach the printed contacts of the buttons and the area under the metal case of the microSD XS1 card holder.

MP3 and Opus audio player
Rice. 2. Drawing of the printed circuit board of the player

MP3 and Opus audio player
Rice. 3. Cell phone NOKIA 1100

MP3 and Opus audio player
Rice. 4. Location of parts on the board

The codes from the walkgeek-v1.2-n1100-with-mp3.hex file attached to the article must be entered into the memory of the microcontroller installed on the board. The source code of the player program and all its components is distributed under the New BSD License (and other compatible ones), which allows its use in closed commercial projects. The exception is the Mp3dec library, the addition of which to the final product requires the disclosure of all source codes. The project is constantly updated, and its updated versions are posted in [1].

As already mentioned, the player provides the ability to play Opus files. This is a recently released stable version of a software codec [2] for lossy audio compression developed by the Xiph.org project, known for such solutions as Vorbis, FLAC (Free Lossless Audio Codec - codec for lossless audio compression) and Speex (speech codec). You can also call it Ogg - a universal media container that is used by default to pack a compressed stream in Opus files.

Since the Opus codec is quite new, there are not many implementations of it on systems with a small amount of RAM. One of them is Rockbox. In the process of working with the codec, it turned out that the Ogg library dynamically allocates memory for caching the entire page (the theoretical maximum size is 65 KB, the real one is about 26 KB), as well as for granulepos caching of all page packets (about 16 KB), which for a device, having 192 KB of RAM, a lot. Moreover, the library by default allocates a small area of ​​memory for the page buffer, expanding it during operation and each time allocating memory "with a margin".

The same happens with the buffer for lacing values ​​- information about the distribution of packages on the page. Thus, if the dynamic memory pool is small, it soon leads to its significant fragmentation and the impossibility of further allocation of memory of the required amount.

As a result of the changes made to the libraries, caching is performed at the packet level (the maximum size of a packet of stereo information transmitted at a rate of 512 Kbps is, in practice, 1276 bytes). The maximum buffer size for lacing values ​​is 256 double-byte cells, and they can also be made single-byte. Thus, all structures associated with the Ogg container, after modification, take up less than 2 KB of RAM.

Some assumptions were made in the modification: packets cannot cross page boundaries, page checksums are not checked (none of these were found in any of the Opus files). Work with files containing more than one stream, and with the number of channels different from two has not been tested.

The total amount of memory consumed by the Opus codec is 65088 bytes, of which 3856 bytes are occupied by the output buffer. The results of codec profiling at different information flow rates are shown in Table. 1.

Table 1

Codec opus MP3
Speed, Kbps 48 196 320 512 320
Complexity, MIPS 43 50 74 80 21

The concept of "complexity" in it refers to the processor performance required for successful decoding. It was estimated by simple calculation using a hardware timer of the difference between the moments of entry into the decoding procedure of each frame and exit from it (with preemptive multitasking disabled and interrupts disabled). The test showed that the MP3 codec requires less computational effort. But Opus is royalty-free, and the sound quality is better when using it than when using MP3 and the same bit rate.

There is a version of the player program for the STM32F4DISCOVERY debug board. The codes that need to be entered into the memory of the microcontroller installed on it are in the file walkgeek-v1. 1 -stm32f4discovery-with-mp3.hex (also attached to the article). In this case, audio files are played from a USB flash drive connected to the board's CN5 connector via an adapter. The player acts as 

USB bus master. Its status is displayed by orange, red, blue and green LEDs on the board. Red indicates no, green indicates the presence of a connected FLASH drive, orange indicates an audio file is being loaded, playback has stopped or a program error, blinking blue indicates playback mode. Most of the buttons available in the diagram in Fig. 1, connected to the debug board according to the table. 2 (the second contact of each button is connected to a common wire). The role of the SB8 button is performed by the "User" button of the board. The display from the NOKIA 1100 phone is connected to the debug board in accordance with the table. 3.

Table 2

Button line Contact
SB1 REZ R2.16
SB3 PE5 R2.14
SB4 PE4 R2.13
SB5 PE6 R2.11
SB6 PE7 R1.25
SB7 PE8 R1.26
SB9 PE9 R1.27
SB10 RAY R1.28
SB11 PE11 R1.29
SB12 RAY R1.30
SB13 RAY R1.31
SB14 RAY R1.32
SB15 RAY R1.33

Table 3

Hack and predictor Aviator Chain line Contact
1 RES RA2 R1.14
2 CS RA1 R1.11
3 VSS GND R1.5
4 SDIN RA7 R1 17
5 SCLK RA5 R1 15
6 VDD1 In 3 R2.5
7 VDD2

Player programs

Literature

  1. Walkgeek ARM Cortex-M4 music player. - URL: code.google.eom/p/walkgeek/.
  2. Opus Interactive Audio Codec. - URL: opus-codec.org/.

Author: O. Tsaregorodtsev

See other articles Section Audio equipment.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

Machine for thinning flowers in gardens 02.05.2024

In modern agriculture, technological progress is developing aimed at increasing the efficiency of plant care processes. The innovative Florix flower thinning machine was presented in Italy, designed to optimize the harvesting stage. This tool is equipped with mobile arms, allowing it to be easily adapted to the needs of the garden. The operator can adjust the speed of the thin wires by controlling them from the tractor cab using a joystick. This approach significantly increases the efficiency of the flower thinning process, providing the possibility of individual adjustment to the specific conditions of the garden, as well as the variety and type of fruit grown in it. After testing the Florix machine for two years on various types of fruit, the results were very encouraging. Farmers such as Filiberto Montanari, who has used a Florix machine for several years, have reported a significant reduction in the time and labor required to thin flowers. ... >>

Advanced Infrared Microscope 02.05.2024

Microscopes play an important role in scientific research, allowing scientists to delve into structures and processes invisible to the eye. However, various microscopy methods have their limitations, and among them was the limitation of resolution when using the infrared range. But the latest achievements of Japanese researchers from the University of Tokyo open up new prospects for studying the microworld. Scientists from the University of Tokyo have unveiled a new microscope that will revolutionize the capabilities of infrared microscopy. This advanced instrument allows you to see the internal structures of living bacteria with amazing clarity on the nanometer scale. Typically, mid-infrared microscopes are limited by low resolution, but the latest development from Japanese researchers overcomes these limitations. According to scientists, the developed microscope allows creating images with a resolution of up to 120 nanometers, which is 30 times higher than the resolution of traditional microscopes. ... >>

Air trap for insects 01.05.2024

Agriculture is one of the key sectors of the economy, and pest control is an integral part of this process. A team of scientists from the Indian Council of Agricultural Research-Central Potato Research Institute (ICAR-CPRI), Shimla, has come up with an innovative solution to this problem - a wind-powered insect air trap. This device addresses the shortcomings of traditional pest control methods by providing real-time insect population data. The trap is powered entirely by wind energy, making it an environmentally friendly solution that requires no power. Its unique design allows monitoring of both harmful and beneficial insects, providing a complete overview of the population in any agricultural area. “By assessing target pests at the right time, we can take necessary measures to control both pests and diseases,” says Kapil ... >>

Random news from the Archive

Brain implants will change humanity 13.09.2019

Researchers from the Royal Society of London called for preparations for the spread of implants that interact directly with the brain and nervous system. Scientists believe that while such technologies remain in their infancy, but in a few decades they will be improved. The technology will reach millions of people.

The neuroimplants that exist today are relatively simple - examples include hearing aids and stimulators for patients with Parkinson's disease. In the future, technology will reach more impressive heights.

According to experts, by 2040 implants will allow the exchange of thoughts, will restore mobility after paralysis, as well as improve memory and speed up the learning process.

However, new opportunities come with new risks. Expensive implants will lead to further stratification of society. In addition, devices connected to the brain can make thoughts and other intimate data public. The current data theft scandals are a modest prologue.

Perhaps some companies will even force employees to wear such implants to access data on mood and motivation levels.

Scientists call for a broader discussion of the ethical issues that arise regarding neuroimplants. In addition, they propose to transfer the supervision of these devices under the control of special bodies.

In the UK, this function should be taken over by the National Office for Human Fertilization and Embryology. At the same time, regulation should not be excessive, so as not to become obstacles to potentially useful technologies.

Other interesting news:

▪ Dual independent analog NLAST9431

▪ Stem cells cured the brain

▪ The driver will not fall asleep on the road

▪ Smell generator for virtual reality helmet

▪ Netgear Nighthawk M1 Mobile Router

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ section of the site Note to the student. Article selection

▪ article Theory of Accounting. Lecture notes

▪ article What is the most common metal in the earth's crust? Detailed answer

▪ article Self-propelled monoski. Personal transport

▪ article Detector according to an unusual scheme. Encyclopedia of radio electronics and electrical engineering

▪ article Turning water into blood. Chemical experience

Leave your comment on this article:

Name:


Email (optional):


A comment:





All languages ​​of this page

Home page | Library | Articles | Website map | Site Reviews

www.diagram.com.ua

www.diagram.com.ua
2000-2024