ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING Analog-to-digital converter from a sound card. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Radio amateur designer 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. 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. 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. Latest news of science and technology, new electronics: A New Way to Control and Manipulate Optical Signals
05.05.2024 Primium Seneca keyboard
05.05.2024 The world's tallest astronomical observatory opened
04.05.2024
Other interesting news: ▪ Seagate Mobile Barracuda and Firecuda Mobile Hard Drives ▪ Industrialization has changed the planet's climate ▪ Male and female perception of colors 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 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: All languages of this page Home page | Library | Articles | Website map | Site Reviews www.diagram.com.ua |