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

Analog-to-digital converter from a sound card. Encyclopedia of radio electronics and electrical engineering

Free technical library

Encyclopedia of radio electronics and electrical engineering / Radio amateur designer

Comments on the article Comments on the article

Today, every PC user is familiar with the term "multimedia". For many, it is associated with high-quality sound, animation, etc. However, the Sound Blaster sound card can be used as an analog-to-digital and digital-to-analog converter with exceptional processing capabilities. A computer with such a card can be used as an oscilloscope, generator or signal analyzer. The fact is that its "heart" is a digital signal processor DSP (Digital Signal Processor). In order to use its capabilities, it is necessary to have direct access to the buffers containing the audio data and the control mode of the DSP, i.e. use the low level interface. In this article, we will consider the device of a sound card and the format of standard types of data files in which data obtained as a result of digitizing signals received at the input of a sound card is stored in the computer's memory. The same files can be synthesized programmatically in order to obtain signals of a given shape.

As a rule, a sound card (Fig. 1) has two dual (stereo) inputs and two identical outputs. The first (line) input is designed for input signals with an amplitude of about 1 V, the second - microphone, for weaker signals. When using a sound card as an analog-to-digital converter, you can use any of these inputs - depending on the level of the signal being processed.

Analog-to-digital converter from a sound card

Data related to multimedia is stored in files in the so-called RIFF format (Resource Interchange File Format - file format for resource exchange) [1]. A RIFF file contains nested chunks (chunk's). The outer fragment consists of a header and a data area (Fig. 2). The first double word of the header contains a four-character code that identifies the data stored in the fragment.

Analog-to-digital converter from a sound card

The second dword of the header is the size of the data area in bytes (excluding the size of the header itself). The data area has a variable length with the condition of its alignment on a word boundary and padding at the end with a zero byte to an integer number of words, if necessary.

The RIFF format does not describe the data format. In practice, a RIFF file can contain any data for multimedia, and the format of the data depends on the type of data.

The area labeled "Data" in Figure 2 may contain other fragments within it. For a file that stores sound data (a wav file), this area contains the data identifier "WAVE", a fragment of the sound data format "fmt" (three characters "fmt" and a space at the end), as well as a fragment of sound data (Fig. 2). The file may additionally contain fragments of other types, so you should not think that the header of the wav file has a fixed format. For example, the file may contain a "LIST" or "INFO" fragment containing information about .copy rights and other additional information.

Let's see how the data is written. First, you need to open the input device, specifying the audio data format for it. Then one or more blocks of memory must be ordered and prepared for input by calling a special function. After that, the prepared blocks need to be passed as necessary to the input device driver, which fills them with recorded audio data. To save the recorded data in a wav-file, the application must generate and write to the application file a wav-file and sound data from the prepared memory blocks filled by the driver input devices.

Below is a program fragment that allows you to write a block of data to a file, which is necessary when using a sound card as an analog-to-digital converter:

uses SysUtils, MMSystem; type TWaveData = array[0..0) of word ;const Discret = 22050;WaveHdr:TWaveHdr=( lpData: nil;(address of the waveform buffer) dwBufferLength: 0;(length, in bytes, of the buffer) dwBytesRecorded: 0;(How much data is in the buffer ) dwUser: 0; dwFlags: 0; dwLoops: 0; IpMext: nil; reserved: 0 ) ec : Discret; nBllockAlign: 1; wBitsPerSample: 1; csSize: 8 ) ;var WaveDate: ^TWaveDate; HSoundDevice: HWaveIn; hfile: HMMIO; res: MMResult;begin with WaveHdr do begindwBufferLehgth : =round(Discret/0);dwBytesRecorded: =round(Discret/10);GetMem(WaveData, dwBytesRecorded);lpData : =PChar(WaveData); end; res : =waveInOpen (@HSoundDevice, WAVE_MAPPER, @WaveFormat, 10); res : =waveInPrepareHeader(HSoundDevice, @WaveHdr, SizeOf(WaveHdr)); res : =waveInUnprepareHeader (HSoundDevice, @WaveHdr,SizeOf(WaveHdr)) ; FreeMem(WaveData); res:=waveInStart(HSoundDevice) ; hfile:=mmio0,0,0pen("d: \work\data_0.txt",nil, MMIO_CREATE or MMIO_READWRITE); mmioWrite(hfile,WaveHdr.IpData, WaveHdr,dwBytesRecorded); mmioClose(hfile,1); waveInReset(HSoundDevice) ; waveInClose(HSoundDevice) ;end.

Unlike the MCI interface, where many parameters are taken by default, the low-level interface requires careful and thorough consideration of all the details of the writing and reading process. As compensation for the extra effort, you get more flexibility and the ability to work not only with audio, but also with arbitrary signals in real time.

Literature

1. Frolov A.V., Frolov G.V. Multimedia for Windows. Programmer's Guide. - M, "DIALOGUE-MEPhI", 1994, 284 p. (Library of the system programmer; V. 15).

Author: O. Baranovsky, Minsk; Publication: N. Bolshakov, rf.atnn.ru

See other articles Section Radio amateur designer.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

A New Way to Control and Manipulate Optical Signals 05.05.2024

The modern world of science and technology is developing rapidly, and every day new methods and technologies appear that open up new prospects for us in various fields. One such innovation is the development by German scientists of a new way to control optical signals, which could lead to significant progress in the field of photonics. Recent research has allowed German scientists to create a tunable waveplate inside a fused silica waveguide. This method, based on the use of a liquid crystal layer, allows one to effectively change the polarization of light passing through a waveguide. This technological breakthrough opens up new prospects for the development of compact and efficient photonic devices capable of processing large volumes of data. The electro-optical control of polarization provided by the new method could provide the basis for a new class of integrated photonic devices. This opens up great opportunities for ... >>

Primium Seneca keyboard 05.05.2024

Keyboards are an integral part of our daily computer work. However, one of the main problems that users face is noise, especially in the case of premium models. But with the new Seneca keyboard from Norbauer & Co, that may change. Seneca is not just a keyboard, it is the result of five years of development work to create the ideal device. Every aspect of this keyboard, from acoustic properties to mechanical characteristics, has been carefully considered and balanced. One of the key features of Seneca is its silent stabilizers, which solve the noise problem common to many keyboards. In addition, the keyboard supports various key widths, making it convenient for any user. Although Seneca is not yet available for purchase, it is scheduled for release in late summer. Norbauer & Co's Seneca represents new standards in keyboard design. Her ... >>

The world's tallest astronomical observatory opened 04.05.2024

Exploring space and its mysteries is a task that attracts the attention of astronomers from all over the world. In the fresh air of the high mountains, far from city light pollution, the stars and planets reveal their secrets with greater clarity. A new page is opening in the history of astronomy with the opening of the world's highest astronomical observatory - the Atacama Observatory of the University of Tokyo. The Atacama Observatory, located at an altitude of 5640 meters above sea level, opens up new opportunities for astronomers in the study of space. This site has become the highest location for a ground-based telescope, providing researchers with a unique tool for studying infrared waves in the Universe. Although the high altitude location provides clearer skies and less interference from the atmosphere, building an observatory on a high mountain poses enormous difficulties and challenges. However, despite the difficulties, the new observatory opens up broad research prospects for astronomers. ... >>

Random news from the Archive

Stereo audio subsystem LM4934 Boomer 30.01.2006

NATIONAL SEMICONDUCTOR Corporation announced the release of the LM4934 Boomer stereo audio subsystem, the industry's first subsystem to integrate both digital and analog inputs for multimedia and Internet telephones.

The subsystem includes a digital input, three analog inputs, audio amplifiers with controlled gain. Power amplifiers are also available: with a power of 500 mV for driving an 8-ohm loudspeaker and with a power of 30 mV for driving headphones. The microcircuit is produced in a miniature package with dimensions of 3,3x3,9 mm.

Other interesting news:

▪ Seagate Mobile Barracuda and Firecuda Mobile Hard Drives

▪ solar chimney

▪ Industrialization has changed the planet's climate

▪ Male and female perception of colors

▪ Sony's high-speed 4K sensor

News feed of science and technology, new electronics

Interesting materials of the Free Technical Library:

▪ site section Lighting. Article selection

▪ article Obstetrics and gynecology. Crib

▪ article What is more likely: death from a lightning strike or from a fallen asteroid? Detailed answer

▪ article Retail worker. Standard instruction on labor protection

▪ article Residential alarm. Encyclopedia of radio electronics and electrical engineering

▪ article Tsvetnaya voditsa. Focus Secret

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