Wav file format and related API explanation

Source: Internet
Author: User

What is a WAV file.
The WAV file directly reflects the size of a sound at each time point, for example, the following waveform:
Take one point for 0.1 seconds each person. The obtained WAV file value is 0, 1,-, 1. Therefore, if we can directly add the data of many wav files, you will hear all the sounds, which is the principle of the mixer.
The following is an analysis of the wav file structure:
We can open a WAV file and view its binary code directly:
C:/user/wave/22.wav
00000000 5249 4646 9cb6 1e00 5741 5645 666d 7420
00000010 1000 0000 0100 0200 2256 44ac 0000
00000020 0200 0800 6461 7461 78b6 1e00 7f7f 7f7f
20170030.7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
20170040.7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
20170050.7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
20170060.7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
20170070.7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
20170080.7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
20170090.7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
201700a0. 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
You can see that the wav file storage format is as follows:
 
"Riff"
×××× File Size
"Wave"
"FMT"
××××Pcmwawformat -- Data Structure Size
××××
...... Data Structure "pcmwaveformat"
××××
Data
×××× Data size
: Data
 
The first is the string "riff", indicating that the File follows a standard format named "resource intercharge format ). The following four bytes indicate the file size. The second is the string "wave" and "FMT", followed by a structure named "pcmwaveformat", followed by the string "data", followed by the data size and all data. The Piff file is a tree structure with the basic unit being "Block". Figure 5.2 shows the "Block" diagram in the wav file.

Fig 5.2
The WAV file consists of two layers: the parent block "riff", two sub-blocks "FMT", and "data. The "FMT" block contains the wav file format information, and the "data" block contains the data information.

2003-7-22 15:29:00

View comments »»»

15:52:38 WAV file editing (capture, merge, insert) implementation principle

To be exact, the editing of a WAV file is actually a combination of files and a new file header.
That's all.

 

18:15:00: Let's talk about APIs such as waveout.

Wait: Let's talk about APIs such as waveout.

 

9:58:58 multimedia processing API

Multimedia Processing API

Waveinaddbuffer sends a buffer to the Sound Input Device
Waveinclose
Waveingetdevcaps obtains the performance of the sound input device.
Waveingeterrortext
Waveingetid
Waveingetnumdevs returns the number of input audio devices.
Waveingetposition: obtains the input position of a sound device.
Waveinmessage sends information to the Sound Input Device
Waveinopen enable Sound Input Device
Waveinprepareheader preparation sound input buffer
Waveinreset
Waveinstart stops the sound input device.
Waveinstop
Waveinunprepareheader clear the prepared sound file header
Waveoutbreakloop interrupt audio output Loop
Waveoutclose
Waveoutgetdevcaps obtains the performance of the sound output device.
Waveoutgeterrortext: Get audio error text
Waveoutgetid
Waveoutgetnumdevs obtains the number of audio output devices.
Waveoutgetpitch: obtains the intensity of sound output.
Waveoutgetplaybackrate: obtains the sound playback rate.
Waveoutgetposition: obtains the sound playback position.
Waveoutgetvolume to obtain the sound volume
Waveoutmessage sends a message to the sound output device.
Waveoutopen enable the sound output device
Waveoutpause pause sound playback
Waveoutprepareheader: data block for sound playback
Waveoutreset
Waveoutrestart Replay
Waveoutsetpitch: Set the waveform output intensity
Waveoutsetplaybackrate
Waveoutsetvolume sets the output volume
Waveoutunprepareheader clear the backup sound data block
Waveoutwrite write sound output device

 

2003-11-24 10:06:16 1 media control interface

1. Media Control Interface

Media control interface (MCI) media control interface is a set of standard interfaces for multimedia devices and files provided by Mircrosoft, its advantage is that it can easily control the vast majority of multimedia devices, including audio, video, album, video and other multimedia devices, without the need to know their internal working conditions. But the ancient saying goes: success and failure. Although it seems to be a great deal, it is far from enough for some advanced applications. For example, although visual c ++ seems omnipotent, it requires programmers to develop their own multimedia engines. For the MCI instruction set, we will only give a brief introduction, focusing on the waveform file mixer.

Control Mode of MCI:

Generally, programmers can use two functions to deal with MCI:

Mcierror mcisendcommand (mcideviceid wdeviceid, uint umsg,
DWORD dwflags, DWORD dwparam );

The command string method sends control commands in a way similar to everyday terms. It is suitable for advanced programming, such as VB and Toolbook.

Mcierror mcisendstring (lpctstr lpszcommand, lptstr lpszreturnstr
ING, uint cchreturn, handle hwndcallback );

The command message method uses professional syntax to send control messages. It is applicable to programming in VC and other languages. This method is used to directly deal with the MCI device.

 

For mcisendcommand, the first parameter specifies the device identifier, which will be provided by the system when the programmer opens the MCI device. The second parameter specifies how to control the device. For details, refer to the "MCI command" column. The third parameter is the access identifier, and the fourth parameter is generally a data structure, which identifies some information required by the program to access the MCI. For more information, see the CD.

For mcisendstring, the first parameter is a control string. The system fills in the returned information with the second parameter. The third parameter specifies the maximum length of the returned information, if the "Y" flag is set for the MCI device, enter the fourth parameter to return the window handle.

Example:

Mcisendcommand (DeviceID, mci_close, null, null); // closes an MCI device;

Mcisendstring ("Open AAA. Avi", 0, 0); // open the file "AAA. Avi ";

The device type of MCI:

The following types of devices are available:

Device description string description
 
Mci_all_device_id all devices
 
Mci_devtype_animation animation Device
 
Mci_devtype_cd_audio cdaudio CD audio
 
Mci_devtype_dat Digital Audio
 
Mci_devtype_digital_video digitalvideo Digital Video
 
Mci_devtype_other other undefined Device
 
Mci_devtype_overlay overlay overlapping video
 
Mci_devtype_scanner Scanner
 
Mci_devtype_sequencer sequencer MIDI sequencer
 
Mci_devtype_vcr video recorder
 
Mci_devtype_videodis videodisc laser video disk
 
Mci_devtype_waveform_audio waveaudio wave audio
 
For an MCI device that is not defined above, you can view the [MCI] section in the system. ini file, for example:

[MCI]

Cdaudio = mcicda. DRV
Sequencer = mciseq. DRV
Waveaudio = mciwave. DRV
Avivideo = mciavi. DRV
Videodisc = mcipionr. DRV
VCR = mcivisca. DRV
Activemovie = mciqtz. DRV
Qtwvideo = mciqtw. DRV
Mpegvideo = C:/progra ~ 1/Xing/xingmp ~ 1/xmdrv95.dll
The last two sentences respectively indicate Apple's QuickTime device, which is named "qtwvidio" and MPEG image device, and the device name is "mpegvideo ".

In MCI Programming, you can either describe a device as a device name or describe a string as a device name. One extreme lazy way is that programmers do not specify a device name in the program, windows automatically identifies the device type based on the file extension.

For example, there are three methods to open a multimedia file:
[1]: Automatic Identification: open a "WAV" File
Mci_open_parms mciopen;
Mciopen. lpstrdevicetype = 0;
Mciopen. lpstrelementname = "aaa.wav ";
Mcisendcommand (null, mci_open, mci_open_element,
(DWORD) & mciopen );

[2]: Specify the device Description: enable the CD player.
Mci_open_parms mciopen;
Mciopen. lpstrdevicetype = (lpstr) mci_devtype_cd_audio;
Mcisendcommand (null, mci_open, mci_open_type | mci_open_type_id,
(DWORD) & mciopen );

[3]: Specify the description string: open an AVI file
Mci_open_parms mciopen;
Mciopen. lpstrdevicetype = "avivideo ";
Mciopen. lpstrelementname = "AAA. Avi ";
Mcisendcommand (null, mci_open, mci_open_type | mci_open_element,
(DWORD) & mciopen );

Note the difference between the third parameter of the function in the three open methods, which will be discussed later.

 

MCI command

The following command is used for MCI:

Mci_break
Set the interrupt key. The default value is Ctrl + break"
 
Mci_capture
Captures the current frame and saves it to a specified file. It is only used for digital videos.
 
Mci_close
Disable the device
 
Mci_configure
The configuration dialog box is only used for digital videos.
 
Mci_copy
Copy Data to clipboard
 
Mci_cue
Delayed playback or recording
 
Mci_cut
Delete data
 
Mci_delete
Delete data
 
Mci_escape
Used only for laser videos
 
Mci_freeze
Frame the display
 
Mci_getdevcaps
Get device information
 
Mci_index
Whether the current screen is displayed. It is only used for VCR devices.
 
Mci_info
Obtain string Information
 
Mci_list
Obtains the number of input devices. It supports digital videos and VCR devices.
 
Mci_load
Load a file
 
Mci_mark
Cancel or make a mark to match mci_seek
 
Mci_mark
Cancel or make a mark to match mci_seek
 
Mci_monitor
Specify a report device for a digital video
 
Mci_open
Enable the device
 
Mci_paste
Paste data
 
Mci_pause
Pause current action
 
Mci_play
Play
 
Mci_put
Set the source, destination, and border rectangle
 
Mci_quality
Define default Device Quality
 
Mci_record
Start recording
 
Mci_reserve
Allocate disk space
 
Mci_restore
Copy a BMP file to the frame buffer
 
Mci_resume
Enable a paused device to restart
 
Mci_save
Save data
 
Mci_seek
Change Media location
 
Mci_set
Set device information
 
Mci_setaudio
Set volume
 
Mci_settimecode
Enable or disable the time code of the VCR Device
 
Mci_settuner
Set vcr device channels
 
Mci_setvideo
Set video Parameters
 
Mci_signal
Set the specified space in the Workspace
 
Mci_status
Get device information
 
Mci_step
Frame skipping by a playback device
 
Mci_stop
Stop playing
 
Mci_sysinfo
Returns the message of the MCI device.
 
Mci_undo
Cancel operation
 
Mci_unfreeze
Restores motion in the video buffer using mci_unfreeze.
 
Mci_update
Update display area
 
Mci_where
Get the device trim rectangle
 
Mci_window
Specify the window and window features of a graphic Device

Commonly used Commands include mci_open, mci_close, mci_play, mci_stop, mci_pause, and mci_status.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.