It will definitely be lost, mp3 is the third layer of lossy compression format of mpeg1. WAV is a sound file format developed by Microsoft. It complies with the RIFF (Resource Interchange File Format) file specification and is used to save audio information resources on the Windows platform. It is widely supported by the Windows platform and its applications. This format It also supports multiple compression algorithms such as MSADPCM, CCITT A LAW, etc., and supports a variety of audio numbers, sampling frequencies and channels. The standard formatted WAV file is the same as the CD format, with a sampling frequency of 44.1K and a 16-bit quantization number, so The sound file quality is almost the same as CD! WAV opening tool is a media player for WINDOWS.
Three parameters are usually used to represent the sound, the number of quantization bits, the sampling frequency and the number of channels. The sound channels are divided into mono and stereo, and the sampling frequencies are generally 11025Hz (11kHz), 22050Hz (22kHz) and 44100Hz (44kHz). However, despite the excellent sound quality, the compressed file size is too large! This is a disadvantage compared to other audio formats. The file size is calculated as:
Capacity occupied by WAV format files = (sampling frequency = 8bit)
Currently, the mobile phones that support WAV design are mainly smart phones, such as Sony Ericsson P910 and Nokia N90, as well as Dopod and other mobile phones using Microsoft OS. However, some other non-smartphone products, if they are promoted to support WAV Most of the formats only support mono.
[Edit this paragraph] WAV analysis
WAVE is the standard WINDOWS file format used for recording. The file extension is "WAV", and the data itself is in PCM or compressed format. type.
The WAV file format is a standard for audio digital storage jointly developed by Microsoft and IBM. It adopts the RIFF file format structure and is very close to the AIFF and IFF formats. Comply with RIFF (Resource Interchange File Format) specification. All WAVs have a file header, which contains the encoding parameters of the audio stream.
As the most classic Windows multimedia audio format, WAV files are widely used. It uses three parameters to represent sound: number of sampling bits, sampling frequency and number of channels.
The sound channels are divided into mono and stereo, and the sampling frequencies are generally 11025Hz (11kHz), 22050Hz (22kHz) and 44100Hz (44kHz). The capacity occupied by WAV files = (sampling frequency × number of sampling bits × channels) × time/8 (1 byte = 8 bit).
WAV has no hard and fast rules for encoding audio streams. In addition to PCM, almost all encodings that support the ACM specification can encode WAV audio streams. A variety of data are used in multimedia applications, including bitmaps, audio data, video data, and peripheral device control information. RIFF provides a method for storing these types of data. The data type contained in a RIFF file is identified by the extension of the file. The data that can be stored in a RIFF file includes:
Audio and video interlaced format data (.AVI), waveform format data (.WAV), bitmap format data (.RDI), MIDI format data (.RMI), palette format (.PAL), multimedia movie (.RMN), animated cursor (. ANI), other RIFF files (.BND).
WAVE files can store data in a large number of formats, and the audio encoding method commonly used is pulse code modulation (PCM). Since the WAV format originates from the Windows/Intel environment, it is stored in Little-Endian byte order.
As one of the sound wave file formats used in multimedia, WAVE files are based on the RIFF format as the standard. RIFF is the abbreviation of English Resource Interchange File Format. The first four bytes of each WAVE file are "RIFF". WAVE files consist of two major parts: file header and data body. The file header is divided into two parts: the RIFF/WAV file identification section and the sound data format description section. The content and format of each part of the WAVE file are shown in the attached table.
There are two main types of common sound files, corresponding to mono (11.025KHz sampling rate, 8Bit sampling value) and dual channel (44.1KHz sampling rate, 16Bit sampling value). The sampling rate refers to the number of times the sound signal is sampled per unit time during the "analog → digital" conversion process. The sampling value refers to the integral value of the sound analog signal in each sampling period.
For a mono sound file, the sampling data is an eight-bit short integer (short int 00H-FFH); for a two-channel stereo sound file, each sampling data is a 16-bit integer ( int), the upper eight bits and the lower eight bits represent the left and right channels respectively.
WAVE file data blocks contain samples represented in pulse code modulation (PCM) format. WAVE files are organized from samples. In a mono WAVE file, channel 0 represents the left channel and channel 1 represents the right channel. In multi-channel WAVE files, samples appear alternately.
Each sample value of the WAVE file is contained in an integer i, whose length is the minimum number of bytes required to accommodate the specified sample length. The low-significant byte is stored first, the bit representing the sample amplitude is placed on the high-significant bit of i, and the remaining positions are 0, so that the data format of 8-bit and 16-bit PCM waveform samples is achieved. WAVE file is one of the sound wave file formats used in multimedia, and it is based on the RIFF format.
RIFF is the abbreviation of English Resource Interchange File Format. The first four
bytes of each WAVE file are "RIFF".
WAVE files are composed of several Chunks. According to the position in the file, it includes: RIFF WAVE
Chunk, Format Chunk, Fact Chunk (optional), Data Chunk. See the picture below for details:
----------------------------------------- ----------
| RIFF WAVE Chunk |
| ID = 'RIFF' |
| RiffType = 'WAVE' |
----------------------------------------------- -----
| Format Chunk |
| ID = 'fmt ' |
------------- ----------------------------------
| Fact Chunk(optional) |< /p>
| ID = 'fact' |
---------------------------- ------------------
| Data Chunk |
| ID = 'data' |
---------------------------------------- p>
Figure 1 Wav format contains Chunk example
RIFF WAVE Chunk
===================== =============
| |Number of bytes occupied| Specific content|
============ ======================
| ID | 4 Bytes | 'RIFF' |
---- ----------------------------------
| Size | 4 Bytes | |
----------------------------------
| Type | 4 Bytes | 'WAVE ' |
----------------------------------
Figure 2 RIFF WAVE Chunk
is marked with 'RIFF', followed by the size field, which is the size of the entire wav file minus the words occupied by ID
and Size Number of sections, i.e. FileLen - 8 = Size. Then there is the Type field, which is 'WAVE', indicating that it is a wav file.
The structure is defined as follows:
struct RIFF_HEADER
{
char szRiffID[4]; // 'R','I' ,'F','F'
DWORD dwRiffSize;
char szRiffFormat[4]; // 'W','A','V','E' p>
};
Format Chunk
=========================== =========================================
| Number of bytes | Specific content |
==================================== ================================
| ID | 4 Bytes | 'fmt ' |< /p>
----------------------------------------------- --------------------------
| Size | 4 Bytes | The value is 16 or 18, 18 means additional information at the end |
----------------------------------------------- ----------------------- ----
| FormatTag | 2 Bytes | Encoding method, generally 0x0001 | |
----------------------------------------------- ----------------------- |
| Channels | 2 Bytes | Number of channels, 1--mono; 2--dual channel | |
---------------------------------- ---------------------------------- |
| SamplesPerSec | 4 Bytes | Sampling frequency | |
--------------------------------------------- -------------------------- |
| AvgBytesPerSec| 4 Bytes | Number of bytes required per second | |= ==> WAVE_FORMAT
--------------------------------------- ----------------------------- |
| BlockAlign | 2 Bytes | Data block alignment unit (each Number of bytes required for sampling) | |
---------------------------------- ---------------------------------- |
| BitsPerSample | 2 Bytes | Each Number of bits required for sampling | |
--------------------------------------------- -------------------------------- |
| | 2 Bytes | Additional information (optional) , determine whether it is present by Size) | |
---------------------------------- ---------------------------------- ----
Figure 3 Format Chunk
Use 'fmt' as the mark. Under normal circumstances, the Size is 16, and there is no additional information at the end; if it is 18
, there are 2 bytes of additional information at the end. The wav format, mainly produced by some software, contains the 2-byte
additional information.
The structure is defined as follows:
struct WAVE_FORMAT
{
WORD wFormatTag;
WORD wChannels;
p>DWORD dwSamplesPerSec;
DWORD dwAvgBytesPerSec;
WORD wBlockAlign;
WORD wBitsPerSample;
};
struct FMT_BLOCK
{
char szFmtID[4]; // 'f','m','t',' '
DWORD dwFmtSize;
WAVE_FORMAT wavFormat;
};
Fact Chunk
============ ======================
| |Number of bytes occupied| Specific content|
=== ===============================
| ID | 4 Bytes | 'fact' | p>
----------------------------------
| Size | 4 Bytes | The value is 4 |
----------------------------------
| data | 4 Bytes | |
-------------------------------- --
Figure 4 Fact Chunk
Fact Chunk is an optional field. Generally, when the wav file is converted by some software, this Chunk is included.
The structure is defined as follows:
struct FACT_BLOCK
{
char szFactID[4]; // 'f','a' ,'c','t'
DWORD dwFactSize;
};
Data Chunk
======= ===========================
| |Number of bytes occupied| Specific content|
< p> ==================================| ID | 4 Bytes | ' data' |
----------------------------------
| Size | 4 Bytes | |
----------------------------------< /p>
| data | | |
-------------------------------- --
Figure 5 Data Chunk
Data Chunk is the place where wav data is actually saved, with 'data' as the label of the Chunk. Then there's
the size of the data. Next is the wav data.
According to the number of channels and the number of sampling bits in the Format Chunk, the bit positions of wav data can be divided into the following forms:
----------- -------------------------------------------------- --------
| Mono | Sample 1 | Sample 2 | Sample 3 | Sample 4 |
| |--------- --------------------------------------------------
| 8bit quantization | channel 0 | channel 0 | channel 0 | channel 0 |
------------------- --------------------------------------------------
| Binaural | Sample 1 | Sample 2 |
| |----------------------- ----------------------------------
| 8bit quantization | Channel 0 (left) | Channel 1 (right) | Channel 0 (left) | Channel 1 (right) |
-------------------------- ---------------------------------------- p>
| | Sample 1 | Sample 2 |
| Mono|----------------------------- ----------------------------------
| 16bit quantization | Channel 0 | Channel 0 | Channel 0 | Channel 0 |
| | (low byte) | (high byte) | (low byte) | (high byte) |
-- -------------------------------------------------- ------------------
| | Sample 1 |
| Two-channel |--------- --------------------------------------------------
| 16bit quantization | Channel 0 (left) | Channel 0 (left) | Channel 1 (right) | Channel 1 (right) |
| | (low byte) | (high byte) | (low byte) | (high byte) |
-------------------------- ---------------------------------------------
< p> Figure 6 wav data bit position arrangementThe Data Chunk header structure is defined as follows:
struct DATA_BLOCK
{
char szDataID [4]; // 'd','a','t','a'
DWORD dwDataSize;
};
[Edit this Section] WAV Features
The advantages of the WAV audio format include: simple encoding/decoding (almost direct storage of the signal from the analog-to-digital converter (ADC)), universal recognition/support, and lossless storage. The main disadvantage of the WAV format is the audio storage space required. This can be an important issue for applications with small storage constraints or low bandwidth. Another potential drawback of the WAV format is the 2G limit in 32-bit WAV files, which has been improved in the W64 format developed for SoundForge.
[Edit this paragraph] WAV support
The Wav format supports MSADPCM, CCITTALaw, CCITT μ Law and other compression algorithms, and supports a variety of audio bits, sampling frequencies and channels, but The disadvantage is that the file size is large (a 44kHz, 16bit Stereo WAV file takes up about 10MB of hard drive space per minute), so it is not suitable for long-term recording.
In Windows, the extension of sound files stored on the hard disk is WAV. WAV records the sound itself, so it takes up a lot of hard drive space. For example: 16-bit 44.1KHZ stereo sound takes up about 10MB of capacity per minute, which is far behind MIDI.
[Edit this paragraph]WAV conversion
AVI and WAV are very similar in file structure, but AVI only has one more video stream. There are many kinds of AVI that we are exposed to, so we often need to install some Decode to watch some AVI. DivX, which we are exposed to more, is a video encoding. AVI can use DivX encoding to compress the video stream. Of course, other methods can also be used. Encoding compression. Similarly, WAV can also use a variety of audio encodings to compress its audio stream. However, what we commonly see are WAVs whose audio streams are encoded by PCM. However, this does not mean that WAV can only use PCM encoding. MP3 encoding can also be used in WAV. , just like AVI, as long as the corresponding dDecode is installed, you can enjoy these WAVs.
Under the Windows platform, WAV based on PCM encoding is the best supported audio format, and all audio software can perfectly support it. Since it can meet higher sound quality requirements, WAV is also The preferred format for music editing and creation, suitable for saving music materials. Therefore, WAV based on PCM encoding is used as an intermediary format and is often used in the mutual conversion of other encodings, such as MP3 to WMA.
[Edit this paragraph] Codec
The WAV file format is a standard for audio digital storage jointly developed by Microsoft and IBM. It adopts the RIFF file format structure. Very close to AIFF and IFF formats. A variety of data are used in multimedia applications, including bitmaps, audio data, video data, and peripheral device control information. RIFF provides a method for storing these types of data. The data type contained in a RIFF file is identified by the extension of the file. The data that can be stored in a RIFF file includes:
# Audio and video interlaced format Data (.AVI)
# Waveform format data (.WAV)
# Bitmap format data (.RDI)
# MIDI format data (.RMI )
# Palette format (.PAL)
# Multimedia movie (.RMN)
# Animated cursor (.ANI)
< p> # Other RIFF files (.BND)RIFF is a binary file format containing nested data structures. Each data structure is called a chunk. Chunks do not have a fixed position in the RIFF file, so offsets cannot be used to locate domain values. The data in a block includes data structures, data streams or other chunks (called sub-blocks), etc. Each RIFF block has the following structure:
typedef struct _Chunk
{
DWORD ChunkId; /*Chunk flag*/
DWORD ChunkSize; /*Chunk size*/
BYTE ChunkData[ChunkSize]; /*Chunk content* /
} CHUNK;
ChunkId consists of 4 ASCII characters and is used to identify the data contained in the chunk. The character RIFF is used to identify the RIFF data block, and the space on the right is an ID of no more than 4 characters. Since this file structure was originally defined for PCs by Microsoft and IBM, RIFF files are written in little-endian byte order, while files in big-endian byte order are marked with 'RIFX'.
ChunkSize (block size) is the length of the data stored in the ChunkData field. The sizes of the ChunkId and ChunkSize fields are not included in this value.
The data contained in ChunkData (chunk content) is arranged in word (WORD) units. If the data length is an odd number, a null (NULL) byte is added at the end.
Subchunks have the same structure as blocks. A sub-block is a block contained within other blocks. Only the RIFF file block 'RIFF' and the list block 'List' can contain sub-blocks. All other blocks can only contain data. A RIFF file is a RIFF block, and all other blocks and sub-blocks in the file are contained in this block.
WAV files can store data in a large number of formats, and the audio encoding method commonly used is pulse code modulation (PCM). Since the WAV format originates from the Windows/Intel environment, it is stored in Little-Endian byte order.
Pulse Code Modulation
Claude E. Shannon's "Mathematical Theory of Communication" published in 1948 laid the foundation for modern communication.
In the same year, engineers at Bell Labs developed PCM technology. Although it was revolutionary at the time, today pulse code modulation is regarded as a very simple lossless encoding format. Audio is collected at fixed intervals and quantized into frequency bands. value, other applications using this encoding method include telephones and CDs. There are three main methods of PCM: standard PCM, differential pulse code modulation (DPCM) and adaptive DPCM. In standard PCM, frequency bands are quantized into bands of linear steps that are used to store absolute magnitudes. What is stored in DPCM is the difference between the front and rear current values, so the storage capacity is reduced by about 25%. Adaptive DPCM changes the quantization step size of DPCM and can compress more information at a given signal-to-noise ratio (SNR).
***Same execution process
In the process of encoding and decoding WAV audio files, the most consistent aspects include the processing and conversion of sampling points and sampling frames. The value of a sampling point represents the audio signal within a given time. A sampling frame consists of an appropriate number of sampling points and can constitute multiple channels of the audio signal. For a stereo signal, one sampling frame has two sampling points, and one sampling point corresponds to one channel. A sample frame is passed as a single unit to the digital-to-analog converter (DAC) to ensure that the correct signal is sent to the respective channels at the same time.
[Edit this paragraph] WAV in VB
In the development and design of multimedia software, sound is a very important multimedia element. Excellent sound design will add a lot of color to the multimedia software. . The sound file in WAV format is the most commonly used sound file format and the easiest to obtain. For example, through the "Recorder" program in Win 95, WAV files can be recorded very simply using a microphone. VB is a quite classic multimedia development tool. There are several main ways to play WAV files in VB.
1. Use OLE controls
Build a form, select the OLE control with the mouse, drag out the OLE area on the form, select New and Sound in the window in Figure 1 and then Press the OK key to complete adding the OLE control to the window.
In this way, you can select the file you want to play in the ResourceDoc property of the OLE control, and double-click the OLE control when the program is running.
In actual programming, it is often necessary to click an icon or button to control sound playback. The implementation method is as follows: first set the VISIBLE property of the OLE control to FALSE, and then set the icon Or write the following program in the click event of the button:
Private Sub Contol_Click()
OLE1.Action = 7
End Sub
< p> 2. Use the MMControl controlVB5.0 provides many controls for designing multimedia. Select the MMControls control in PROJECT/COMPENENTS/CONTROLS, and a multimedia control object will appear on the form. On this object There are different graphic function logos, and their names from left to right are Pre, Next, Play, Pause, Back, Step, Stop, Record, and Eject.
This multimedia control can play sounds in multiple formats, and the program code for playing WAV format sound files
Private Sub form_load()
MMControl1.DeviceType = " waveaudio"
MMControl1.filename = "c:\win95\media\ding.wav"
MMControl1.Command = "open"
End Sub 'The following Is the code written for the graphic identification Play event
Private Sub MMControl_playclick(cancel As Integer)
MMControl1.Command = "play"
End Sub
When running this program, the Play button in the MMControl control is activated. Click this button to play the ding.wav file.
In actual software design, it is more often the case that the mouse clicks a button or icon to control the playback of the sound. The implementation method is as follows: first set the VISIBLE attribute of the MMControl control to FALSE, and then Write the following program in the click event of the icon or button:
Private Sub Control1_Click()
MMControl1.Command = "play"
End Sub
p>WAV files can still be played by clicking the corresponding button or icon when running the program. Use self-designed buttons or icons to replace fixed buttons in multimedia controls to design a more flexible and convenient user interface.
3. Use VB API functions
Enter the following code in the DECLARATIONS of the form:
P private Declare Function sndPlaySound Lib "winmm. dll" Alias ??"sndPlaySoundA" (ByVal_lpszSoundName As String, ByVal uFlags As Long) As Long
'lpszSoundName is a string variable representing a file name in WAV format.
'uFlags are used to set various options for playback status. When the parameter value is 0X00, synchronous playback is achieved, and when the parameter value is 0X01, asynchronous playback is achieved.
Enter the following code in the click event of the command button:
Private Sub Command1_Click()
Dim plays As Long
plays = sndPlaySound("E:\WINDOWS\MEDIA\DING.WAV", &H0)
End Sub
Click the command button during runtime to play the WAV file.