Communicate sound in Internet (2)

zhaozj2021-02-08  360

member

Description

PWFX

A TWAVEFORMATEX structure pointer is used to receive results (here we actually use tacmformat).

CBWFX

The buffer size of the received result is received.

CBSTRUCT

Structural size.

Another member worth mentioning is FDWStyle, which includes a flag to specify additional information in the format. Especially the following signs:

ACMFORMATCHOOSE_Stylef_inittowfxStruct

This flag indicates that the buffer pointing by the PWFX already includes a valid format. After the ACMFormatch function is called, a format selection dialog is displayed, and the effective format will be displayed as the default.

Can you convert it?

One reason is that there is no CODEC on a machine that may not have another machine. This causes you to read a sound format, but you can't generate this sound format. Fraunhoffer IIS MP3 CODEC has this issue. Under Windows 9x and Windows NT, we can generate an MP3 file, but in Windows 2000, we remove this feature L. The result is in Windows 2000 we can listen to MP3, when we can't generate MP3, unless we pay a money, Faint .

Another reason is that not all ACM formats can be converted to each other. For example, we cannot transform between the following formats:

GSM 8-bit mono> MP3 8-bit mono

Although it cannot be directly converted, indirect conversion can be indirect via an intermediate format, which is usually a PCM format because most of the CODEC supports conversion in PCM format. The new conversion path is turned:

GSM 8-bit mono> PCM 8-bit mono> MP3 8-bit mono

The converted to "MP3 16-bit stereo" also needs to increase, which is to convert 8-bit PCM format to 16-bit PCM format.

ACM's potential skills

It may be seen from the above introduction to the ability of the ACM, just convert a media format to another. However, I think I need to write a workload of the codec that can be used for the Internet, such as the MP3 compressed function, you will find that ACM is really a good stuff, the price is cheap and fun.

At the same time, imagine how simple it has an Internet phone, first get the input sound data from the microphone, compresses a suitable low-band-wide stream format, and then passed through the TCP / IP protocol to the destination computer. At the same time, the destination computer receives the compressed data, unzipped, and finally played through the speaker.

The potential skills of ACM are here, and there are quite a few ACM CODECs to map WAVE format, which means they can play or record audio as a standard wave device. One of the most important requirements of the Internet phone is real-time.

For example, we can easily open a GSM's voice input source. Once we receive data from the wave input device, the data has been compressed, and can be transferred immediately. At the same time, once the data is received via TCP / IP Socket, we can play it immediately by wave output devices.

Pay attention to the standard PCM format data is too big for real-time voice transmission through Modem, and GSM 6.1 can achieve real-time effects as long as 1.5k / sec, and 16 mono MP3 only need 2K / Sec bandwidth.

In addition, for the MP3 format, it can be used as a play format, but it is not suitable as an input format (because only the MP3 CODEC on the Windows NT platform supports MP3 encoding), usually we need to manually convert MP3 with other programs, so It is not suitable for applications on the Internet phone, but it is very suitable for network dot, because its compression is higher, and the sound quality is less.

The principle is that it is simple as described above, but many things always say, it is difficult to do. So, the following implementation of several controls and programs to actually demonstrate. Since the code is long, it will not be detailed here, just simply explain. Control

l TACMCONVERTER: This control has two functions. First, it can convert data between two different media formats. Second, this control can be used to specify an input and output format of the ACM stream. (Control Editor with Right-click Callout Control You can call the ACMFORMATCHOOSE function display format selection dialog to specify the format when design.

l TACMIN: Used to receive data from the microphone, we use standard PCM formats or other wave input devices to record data.

l TACMOUT: This control is used to play back the sound. The Numpffers property can be used to specify the number of buffers used before starting playback. This is not very significant for real-time audio transmission, but it is very convenient to broadcast audio broadcast on the Internet, while connecting additional audio data when connecting data fluctuations.

Demonstrate

The first example uses the TACMCONVERTOR control to specify the input and output format, then open an ACMIN and ACMOUT controls. The data entered by the microphone is played back, but there is a little delay to generate a little response.

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

New Post(0)