VB.NET implementation of DirectSound9 (9) implementation oscilloscope

xiaoxiao2021-03-06  14

Keywords: player oscilloscope vb.net DirectSound9 Author: Dong Jun containing

Reprint, please indicate from http://blog.9cbs.net/a11s

As the most basic function of a player. For example, Haojie Winamp MediaPlayer Real QuickTime has its own oscilloscope. Some portions also provide interface allows Plugin to add more graphic effects.

Many people doing the player without this basic function, which is probably because most of them use MediaPlayer or Realone controls. As for these, this article is not discussed. This article describes some basic knowledge, and the step method of implementation. It may be used in some knowledge of DirectSound and DirectDraw.

1 DirectSoundCapture: Starting from the recording

Let's take a look at the recording, then we have buffer used to write data. These data is actually we used to show waves. Just need to have changed. You can display the contents of the buffer directly.

2 times DirectSound

Our New has read WAV, next step nature is Play. Note that you will find a read () method, you can read the contents of the buffer. Take it out to see what we have written at the time.

3-drawer

It is not enough to use the number because we have used to see the image to perceive the changes of the sound. Then we can consider using DirectDraw to image buffer content. First use the read () method to get a BYTE (), then use for loop To draw, as for when to call read (), you can use a Timer. Note: The purpose of this is to illustrate the law of data and images in the inside. Instead of perfect oscilloscope. Related DirectDraw can see I originally sent it. Host DirectDraw9. Because in order to ensure the speed, you can't think of a better way except DDRAW.

The lower right is the image drawn (thank you for the FPS algorithm provided by the wind) Click to enlarge 1024x768 This blog I don't usually use

Depending on the change of the varying image, the response will occur. But you will feel different from WinAmp. The following will explain it in detail. Now you are "knowing it". This is actually an oscilloscope for Windows recorders.

4 About RIFF files

After the last WAV Capture, what should be understood. According to the result of the A / D conversion, store it to the buffer, then format it according to the different file format (different size). No compressed WAV actual The result of a para / d conversion plus the file head. The conversion is due to the transfer of the analog signal, and the change in the sound is essentially a continuous curve. Interesting, you can do a Wave Editor yourself. Draw a sound using the mouse

5 A / D D / A conversion does not want to know how to jump, tell you "so,"

Understand it, you can do your equalizer. But this article will not discuss it first.

Sample rate: The frequency of occurrence of A / D conversion, please refer to the interface technology single-chip microcomputer. Because I don't know very well, I hope that you can criticize.

The process of simulating audio is converted into digital audio, saying is called sampling, simply, is to record the sound of 1 second length through the waveform sample, how many data needed. The sound of 44kHz sampling rate is to spend 44,000 data to describe 1 second sound waveform. In principle, the higher the sample rate, the better the sound of the sound.

Number: In short, it is precision, such as 24-bit conversion accuracy.

In fact, there is also a sound level. You don't need to do too much attention here. (Mainly afraid of mistake)

Combining the characteristics of the RIFF file, you can know how much buffer should be read (), then what meanings in each byte

6 real oscilloscope, similar WINAMP

They are with how much HZ, from 1k to 10k to 32K to ....

In fact, our data is integrated, calculated from 0 to 1k, and then accumulated. Displayed on the oscilloscope.

What we just showed is "content", WinAmp shows "quantity" because people's ear is more sensitive to a certain paragraph, and do not want the machine to sample. A simple example. People can feel the bass, then Winamp At an alternative area, it can see rapid growth, and our original oscilloscope can't see it. It is not stressful to see the volume of the volume.

7 Graphical oscilloscope and external interface

The drawing process is actually a drawing function, you pass the "Features" of this paragraph (even passing the entire buffer) it will draw a response according to the parameter, of course, you can increase your own features, such as commonly used attenuation (sound After the end, I didn't have an image, but the gradually disappeared) This is connected, and people feel more comfortable. External interface, anyone can use him to do their own graphic oscilloscope.

Please refer to the principle of Plugin and the process of production, and strongly recommends learning Winamp's

8 Other format files.

The above is only for WAV. Other formats, such as MP3, can't do it directly, but the principle is the same. After all play, you need to perform D / A conversion. You need to convert MP3 results to similar Riff Buffer, then play. This is only

======= End ==============

转载请注明原文地址:https://www.9cbs.com/read-49795.html

New Post(0)