[Repost] Wave Files

xiaoxiao2021-03-06  56

Source: http://www.sonicspot.com/guide/wavefiles.html

OverviewThe Wave file format is Windows' native file format for storing digital audio data. It has become one of the most widely supported digital audio file formats on the PC due to the popularity of Windows and the huge number of programs written for the platform. Almost every modern program that can open and / or save digital audio supports this file format, making it both extremely useful and a virtual requirement for software developers to understand. The following specification gives a detailed description of the structure and inner workings of this format.

Data FormatsSince The Wave File Format Is Native To Windows and Therefor Intel Processors, All Data Values ​​Are Stored In Little-Endian (Least Significant Byte First) Order.

StringsWave files may contain strings of text for specifying cue point labels, notes, etc. Strings are stored in a format where the first byte specifies the number of following ASCII text bytes in the string. The following bytes are of course the ASCII character bytes that Make Up The Text String. Pascal Program Will Notice That this is the same format buy for pascal strings.

7'E'''x''a'' M'p'l'l''E '

Wave String Format EXAMPLE

File structure

Basic Wave File Layout

Chunk ID "Riff" chunk data size

Riff Type ID "Wave"

Chunk ID "FMT" Chunk Data Sizesample Format Info

Chunk ID "Data" Chunk Data Sizedigital Audio Samples

Chunk Header

Chunk Data Bytes

Wave Files Use the Standard

RIFF structure which groups the files contents (sample format, digital audio samples, etc.) into separate chunks, each containing it's own header and data bytes. The chunk header specifies the type and size of the chunk data bytes. This organization method allows programs that do not use or recognize particular types of chunks to easily skip over them and continue processing following known chunks. Certain types of chunks may contain sub-chunks. For example, in the diagram to the right, you can see that the "fmt" and "data" chunks are actually sub-chunks of the "RIFF" chunk.One tricky thing about RIFF file chunks is that they must be word aligned. This means that their total size must be a multiple of 2 bytes (ie. 2, 4, 6, 8, and so on). If a chunk contains, causing it not to be word aligned, an extra padding byte with a value of zero must follow the last data byte. This extra padding byte Is Not Counted in The Chunk Size, Therefor a Program Must Always Wor D Align A Chunk Headers Size Value in Order To Calculate The Offset of The Following Chunk.

Wave File Header -. RIFF Type ChunkWave file headers follow the standard RIFF file format structure The first 8 bytes in the file is a standard RIFF chunk header which has a chunk ID of "RIFF" and a chunk size equal to the file size minus the 8 bytes used by the header. The first 4 data bytes in the "RIFF" chunk determines the type of resource found in the RIFF chunk. Wave files always use "WAVE". After the RIFF type comes all of the Wave file chunks that define The Audio Waveform.

Offsetsizedscriptionvalue0x004chunk ID "riff" (0x52494646) 0x044chunk data size (file size) - 80x084riff type "Wave" (0x57415645) 0x10Wave Chunks

Riff Type Chunk Values

Wave File ChunksThere are quite a few types of chunks defined for Wave files. Many Wave files contain only two of them, specifically the Format Chunk and the Data Chunk. These are the two chunks needed to describe the format of the digital audio samples and the samples themselves. Although it is not required by the official Wave file specification, it is good practice to place the Format Chunk before the Data Chunk. Many programs expect the chunks to be stored in this order and it is more sensible when streaming digital audio from a slow, linear source such as the Internet. If the format were to come after the data, all of the data and then the format would have to be streamed before playback could start correctly. All RIFF Chunks and therefore Wave Chunks are stored in the FOLLOWING FORMAT. NOTICE THAT Even The Above Mentioned Riff Type Chunk Conforms To this format.

Offsetsizedescription0x004chunk id0x044chunk data size0x08chunk data bytes

Riff chunk format

The rest of this document goes through the different types of Wave chunks, describing the format of their data bytes and what they mean. You can use the table of contents at the beginning of this document to help find the chunk type you are interested in.

Format Chunk - "fmt" The format chunk contains information about how the waveform data is stored and should be played back including the type of compression used, number of channels, sample rate, bits per sample and other attributes.

OffsetSizeDescriptionValue0x004Chunk ID "fmt" (0x666D7420) 0x044Chunk Data Size16 extra format bytes0x082Compression code1 - 65,5350x0a2Number of channels1 - 65,5350x0c4Sample rate1 - 0xFFFFFFFF0x104Average bytes per second1 - 0xFFFFFFFF0x142Block align1 - 65,5350x162Significant bits per sample2 - 65,5350x182Extra format bytes0 - 65 , 5350x1aextra Format Bytes *

Wave Format Chunk Values, * Read Following Text for Details

Chunk ID and Data SizeThe chunk ID is always "fmt" (0x666D7420) and the size is the size of the standard wave format data (16 bytes) plus the size of any extra format bytes needed for the specific Wave format, if it does not contain uncompressed PCM data. Note the chunk ID string ends with the space character (0x20). Compression CodeThe first word of format data specifies the type of compression used on the Wave data included in the Wave chunk found in this "RIFF" chunk. The FOLLOWING IS A List of the Common Compression Codes Used Today.

CodeDescription0 (0x0000) Unknown1 (0x0001) PCM / uncompressed2 (0x0002) Microsoft ADPCM6 (0x0006) ITU G.711 a-law7 (0x0007) ITU G.711 μ-law17 (0x0011) IMA ADPCM20 (0x0016) ITU G.723 ADPCM ( Yamaha) 49 (0x0031) GSM 6.1064 (0x0040) ITU G.721 ADPCM80 (0x0050) MPEG65, 536 (0xfff) Experimental

Common Wave Compression Codes

Number of ChannelsThe number of channels specifies how many separate audio signals that are encoded in the wave data chunk. A value of 1 means a mono signal, a value of 2 means a stereo signal, etc. Sample RateThe number of sample slices per second. This value is unaffected by the number of channels. Average bytes per SecondThis value indicates how many bytes of wave data must be streamed to a D / A converter per second in order to play the wave file. This information is useful when determining if data can be streamed from the source fast enough to keep up with playback This value can be easily calculated with the formula:.. AvgBytesPerSec = SampleRate * BlockAlign Block AlignThe number of bytes per sample slice This value is not affected by the number of channels and can be calculated with the formula: BlockAlign = SignificantBitsPerSample / 8 * NumChannels Significant bits Per SampleThis value specifies the number of bits used to define each sample This value is usually 8, 16, 24 or. 32. If the number of bits is not byte aligned (a multiple of 8) then the number of bytes used per sample is rounded up to the nearest byte size and the unused bytes are set to 0 and ignored.Extra Format BytesThis value specifies how many additional format bytes follow. It does not exist if the compression code is 0 (uncompressed PCM file) but may exist and have any value for other compression types depending on what compression information is need to decode the wave data. If this value is not Word Aligned (a multiple of 2), Padding SHOULD BE ADDED to THE End of this Data To Word Align It, But The Value Should Remain Non-Aligned.

Data Chunk - "data" The Wave Data Chunk contains the digital audio sample data which can be decoded using the format and compression method specified in the Wave Format Chunk If the Compression Code is 1 (uncompressed PCM), then the Wave Data contains raw. sample values. This document explains how an uncompressed PCM data is stored, but will not get into the many supported compression formats.Wave files usually contain only one data chunk, but they may contain more than one if they are contained within a Wave List chunk ("WAVL").

OffsetLengthTypedescriptionValue0x004char [4] Chunk ID "DATA" (0x64617461) 0x044dwordchunk sizedepends on sample length and compression0x08

Sample Data

Data Chunk Format

Multi-channel digital audio samples are stored as interlaced wave data which simply means that the audio samples of a multi-channel (such as stereo and surround) wave file are stored by cycling through the audio samples for each channel before advancing to the next sample time. This is done so that the audio files can be played or streamed before the entire file can be read. This is handy when playing a large file from disk (that may not completely fit into memory) or streaming a file over the Internet. THE VALUES in The Diagram BELOW Would Be Stored In a Wave File in The ORDER THEY Are Listed in The Value Column (Top To Bottom).

TimechannelValue01 (Left) 0x00532 (Right) 0x002411 (LEFT) 0x00572 (Right) 0x002921 (Left) 0x00632 (Right) 0x003C

Interlaced Stereo Wave Samples

One point about sample data that may cause some confusion is that when samples are represented with 8-bits, they are specified as unsigned values. All other sample bit-sizes are specified as signed values. For example a 16-bit sample can range from -32,768 to 32,767 with a mid-point (silence) at 0.As mentioned earlier, all RIFF chunks (including WAVE "data" chunks) must be word aligned. If the sample data uses an odd number of bytes, a padding byte ............................

Fact Chunk -. "Fact" A fact chunk stores compression code dependant information about the contents of the Wave file It is required by all compressed WAVE formats and if the waveform data is contained inside a "wavl" LIST chunk, but is not required for The Uncompressed PCM Wave Format Files (Compression Code 1) That Contain The Waveform Data Inside A "Data" Chunk.

Offsetsizedescriptionvalue0x004chunk ID "fact" (0x66616374) 0x044chunk data sizedepends on format0x08

Format Dependant Data

Fact Chunk Format

Format Dependant DataThere is currently only one field defined for the format dependant data. It is a single 4-byte value that specifies the number of samples in the waveform data chunk. This value can be used with the Samples Per Second value specified in the format Chunk to Calculate The WaveForms Length in Seconds.

As new WAVE formats are introduced, the fact chunk will be expanded, appending fields after the defined number of samples field. Applications can use the fact chunk size to determine which fields are present in the chunk.

Wave List Chunk - "wavl" A wave list chunk is used to specify several alternating "slnt" and "data" chunks These chunks can help reduce a Wave file's size while specifying audible segments of samples when a stream of digital audio contains several periods. of silence.This type of chunk is considered to be an abuse of the Wave file format by many programmers (including myself) and it's support is not recommended. Also many programs will not recognize this type of chunk, simply ignoring it. This form of Compression Unnecessarily Complicates The Structure of a Wave File and Could Be Better Implement in Other Ways, Including The Use of Several Existing Compression Formats.

OffsetSizeDescriptionValue0x004Chunk ID "slnt" (0x736C6E74) 0x044Chunk Data Sizedepends on size of data and slnt chunks0x08List of Alternating "slnt" and "data" ChunksWave List Chunk Format

Silent Chunk - "slnt" A silent chunk is used to specify a segment of silence that will last some duration of samples It is always contained within a wave list chunk While this chunk represents silence, it does not necessarily define a zero volume or.. baseline sample. It actually holds the last sample value present in the preceding data chunk in the wave list chunk. If there is no preceding data chunk in the wave list chunk, a baseline value should be used (127 for 8-bit data, 0 For 16-Bit or Higher Data). This May Seem Trivial, But if Not Followed, May Cause Undesired Clicks and Pops in The Audio Signal.

Offsetsizedescriptionvalue0x004chunk ID "SLNT" (0x736c6e74) 0x044chunk data size40x084number of storent samples0 - 0xfffffffff

Silent Chunk Format

Number of Silent SamplesThis value specifies the number of silent samples that appear in the waveform at this point in the wave list chunk.Cue Chunk - "cue" A cue chunk specifies one or more sample offsets which are often used to mark noteworthy sections of audio . for example, the beginning and end of a verse in a song may have cue points to make them easier to find. The cue chunk is optional and if included, a single cue chunk should specify all cue points for the "WAVE" chunk. No more Than One Cue Chunk Is Allowed in a "Wave" Chunk.

Offsetsizedescriptionvalue0x004chunk ID "CUE" (0x63756520) 0x044chunk data sizedepends on num cue pointsnumber of Cue Points in list0x0c

List of cue point

Cue Chunk Format

Chunk ID and Data SizeThe chunk ID for a cue chunk is always "cue" (0x666D7420). Note that the chunk ID string ends with the space character (0x20). The chunk data size is equal to the size of the Num Cue Points value (4) plus the number of following cue points multiplied by the size of each cue point's data (24) The following formula can be used to calculate a Cue Chunk's data size:. ChunkDataSize = 4 (NumCuePoints * 24) Num Cue PointsThis value SPECIFIES INTSCRIPTION OF CUE POINTS IN THIST OF Cue Points IS SIMPLY A SET OF CUE POINTS IS SIMPLY A SET OF CUE POINTS IS SIMPLY A Set of Consecutive Cue Point Descriptions That Follow The Format Described Below.

OffsetSizeDescriptionValue0x004IDunique identification value0x044Positionplay order position0x084Data Chunk IDRIFF ID of corresponding data chunk0x0c4Chunk StartByte Offset of Data Chunk * 0x104Block StartByte Offset to sample of First Channel0x144Sample OffsetByte Offset to sample byte of First Channel

Cue Point FormatIDEach cue point has a unique identification value used to associate cue points information in other chunks. For example, a Label chunk contains text that describes a point in the wave file by referencing the associated cue point. PositionThe position specifies the sample offset with associated with the cue point in terms of the sample's position in the final stream of samples generated by the play list. Said in another way, if a play list chunk is specified, the position value is equal to the sample number at which this cue point will occur during playback of the entire play list as defined by the play list's order. If no play list chunk is specified this value should be 0. Data Chunk IDThis value specifies the four byte ID used by the chunk containing the sample that corresponds to this Cue Point. A Wave File with no Play List is always "data". A Wave File with a Play List Containing Both Sample Data and Silence May Be Either "Data" or "SLNT". Chunk Startthe Chunk STA rt value specifies the byte offset into the Wave List Chunk of the chunk containing the sample that corresponds to this cue point. This is the same chunk described by the Data Chunk ID value. If no Wave List Chunk exists in the Wave file, this value is 0. If a Wave List chunk exists, this is the offset into the "wavl" chunk. The first chunk in the Wave List chunk would be specified with a value of 0. Block StartThe Block Start value specifies the byte offset into the " Data "OR" SLNT "

Chunk to the start of the block containing the sample. The start of a block is defined as the first byte in uncompressed PCM wave data or the last byte in compressed wave data where decompression can begin to find the value of the corresponding sample value.Sample OffsetThe Sample offset specifies an offset into the block (specified by Block Start) for the sample that corresponds to the cue point. In uncompressed PCM waveform data, this is simply the byte offset into the "data" chunk. In compressed waveform data, this Value Is Equal to the Number of Samples (May Or May Not Be bytes) from the block start to the cue point.

Playlist Chunk -. "Plst" The playlist chunk specifies the play order of a series of cue points The cue points are defined in the cue chunk, somewhere else in the file A playlist consists of an array of segments, each containing information about what. .

OffsetsizedescriptionValue0x004chunk ID "PLST" (0x736c6e74) 0x044chunk data sizenum segments * 120x084number of segments1 - 0xffffff0x0a

List of segments

Playlist chunk format

Number of SegmentsThis value specifies the number of following segments in the playlist chunk. List of SegmentsA list of segments is simply a set of consecutive segment descriptions that follow the format described below. The segments do not have to be in any particular order because each segments Associated Cue Point Position is buy to determine the play order.

Offsetsizedescriptionvalue0x004cue point id0 - 0xffffffff0x04411LENGTH (In Samples) 1 - 0xffffffff0x084number of reviews1 - 0xfffffffffFFFSEGMENT FORMAT

Cue Point IDThe Cue Point ID specifies the starting sample for this segment by providing the value of a Cue Point defined in the Cue Point List. The ID that associates this segment with a Cue Point must be unique to all other segment Cue Point IDs. LengthThe Segment Length Specifies The Number of Samples To Play / Loop from the Starting Sample Defined by The Associated Cue Point.

Number of Repeatsthe Number of Repeats Dermines How Many Times this segment shouth be looped before playback shop ship Continie onto the next segment.

Associated Data List Chunk - "List" An Associated Data List Chunk is buy to define text labels and names which are associated with the cue points to provide each text label or name a position.

Offsetsizedescriptionvalue0x004chunk ID "list" (0x6c696e74) 0x044chunk data sizedepends on contained text0x084type ID "ADTL" (0x6164746c) 0x0c

List of text labels and names

Associated Data List Chunk Format

TYPE IDTHE TYPE ID IS Used to Identify The Type of Associated Data List and is always "adtl".

List of Text Labels and NamesThe list of text labels and names is a list of assorted chunks that define text in different ways. The three main chunk types that are used in WAVE files are the Label Chunk, Note Chunk and Labeled Text Chunk.

Label Chunk -. "Labl" The label chunk is always contained inside of an associated data list chunk It is used to associate a text label with a Cue Point This information is often displayed next to markers or flags in digital audio editors..

Offsetsizedescriptionvalue0x004chunk ID "labl" (0x6c61626c) 0x044chunk data sizedepends on contained text0x084cue point id0 - 0xffffffff0x0ctext

Label Chunk Format

Cue Point IDThe Cue Point ID specifies the sample point that corresponds to this text label by providing the ID of a Cue Point defined in the Cue Point List. The ID that associates this label with a Cue Point must be unique to all other label Cue Point Ids.

TextThe text is a null terminated string of characters. If the number of characters in the string is not even, padding must be appended to the string. The appended padding is not considered in the label chunk's chunk size field.

Note Chunk - "note" The label chunk is always contained inside of an associated data list chunk It is used to associate a text comment with a Cue Point This information is stored in an identical fashion to the labels in the label chunk...

Offsetsizedescriptionvalue0x004chunk ID "Note" (0x6e6f7465) 0x044chunk data sizedepends on contained text0x084cue point id0 - 0xffffffff0x0c

TEXT

Label Chunk Format

Cue Point IDThe Cue Point ID specifies the sample point that corresponds to this text comment by providing the ID of a Cue Point defined in the Cue Point List. The ID that associates this label with a Cue Point must be unique to all other note chunk Cue Point IDs.

TextThe text is a null terminated string of characters. If the number of characters in the string is not even, padding must be appended to the string. The appended padding is not considered in the note chunk's chunk size field.

Labeled Text Chunk - "ltxt" The labeled text chunk is always contained inside of an associated data list chunk It is used to associate a text label with a region or section of waveform data This information is often displayed in marked regions of a waveform.. in digital audio editors.OffsetSizeDescriptionValue0x004Chunk ID "ltxt" (0x6C747874) 0x044Chunk Data Sizedepends on contained text0x084Cue Point ID0 - 0xFFFFFFFF0x0c4Sample Length0 - 0xFFFFFFFF0x104Purpose ID0 - 0xFFFFFFFF0x122Country0 - 0xFFFF0x142Language0 - 0xFFFF0x162Dialect0 - 0xFFFF0x182Code Page0 - 0xFFFF0x1A

TEXT

Label Chunk Format

Cue Point IDThe Cue Point ID specifies the starting sample point that corresponds to this text label by providing the ID of a Cue Point defined in the Cue Point List. The ID that associates this label with a Cue Point must be unique to all other note chunk Cue Point IDs. Sample LengthThe sample length defines how many samples from the cue point the region or section spans. Purpose IDThe purpose field specifies what the text is used for. for example a value of "scrp" means script text, and "capt" means close-caption. There are several more purpose IDs, but they are meant to be used with other types of RIFF files (not usually found in WAVE files). Country, Language, Dialect and Code PageThese fields are used to specify information about the .

TextThe text is a null terminated string of characters. If the number of characters in the string is not even, padding must be appended to the string. The appended padding is not considered in the note chunk's chunk size field.

Sampler Chunk - "smpl" OffsetSizeDescriptionValue0x004Chunk ID "smpl" (0x736D706C) 0x044Chunk Data Size36 (Num Sample Loops * 24) Sampler Data0x084Manufacturer0 - 0xFFFFFFFF0x0C4Product0 - 0xFFFFFFFF0x104Sample Period0 - 0xFFFFFFFF0x144MIDI Unity Note0 - 1270x184MIDI Pitch Fraction0 - 0xFFFFFFFF0x1C4SMPTE Format0, 24, 25, 29 , 300X204SMPTE OFFSET0 - 0XFFFFFFF0X244NUM SAMPLE LOOPS0 - 0xFFFFFFFF0X284Sampler Data0 - 0xffffffff0x2c

List of sample loops

Sampler chunk format

ManufacturerThe manufacturer field specifies the MIDI Manufacturer's Association (MMA) Manufacturer code for the sampler intended to receive this file's waveform. Each manufacturer of a MIDI product is assigned a unique ID which identifies the company. If no particular manufacturer is to be specified, a value Of 0 Should Be.

The value is stored with some extra information to enable translation to the value used in a MIDI System Exclusive transmission to the sampler. The high byte indicates the number of low order bytes (1 or 3) that are valid for the manufacturer code. For example , the value for Digidesign Will BE 0x01000013 (0x13) and the value for Microsoft Will BE 0x30000041 (0x00, 0x00, 0x41). See The Midi Manufacturers List for a list.

ProductThe product field specifies the MIDI model ID defined by the manufacturer corresponding to the Manufacturer field. Contact the manufacturer of the sampler to get the model ID. If no particular manufacturer's product is to be specified, a value of 0 should be used.

Sample PeriodThe sample period specifies the duration of time that passes during the playback of one sample in nanoseconds (normally equal to 1 / Samplers Per Second, where Samples Per Second is the value found in the format chunk) .MIDI Unity NoteThe MIDI unity note value has the same meaning as the instrument chunk's MIDI unshifted Note field which specifies the musical note at which the sample will be played at it's original sample rate (the sample rate specified in the format chunk).

MIDI Pitch FractionThe MIDI pitch fraction specifies the fraction of a semitone up from the specified MIDI unity note field. A value of 0x80000000 means 1/2 semitone (50 cents) and a value of 0x00000000 means no fine tuning between semitones.

SMPTE FORMATTHE SMPTE FORMAT Specifier The Society of Motion Pictures and Television E Time Format Used in The Following Smpte Offset Field. If A Value of 0 IS Set, SMPTE Offset Should Also Be set to 0.

VALUESMPTE FORMAT0NO SMPTE OFFSET2424 FRAMES Per Second2525 Frames Per Second2930 Frames Per Second With Frame Dropping (30 Drop) 3030 Frames Per Second

SMPTE FORMAT VALUES

SMPTE OffsetThe SMPTE Offset value specifies the time offset to be used for the synchronization / calibration to the first sample in the waveform. This value uses a format of 0xhhmmssff where hh is a signed value that specifies the number of hours (-23 to 23) , mm is an unsigned value that specifies the number of minutes (0 to 59), ss is an unsigned value that specifies the number of seconds (0 to 59) and ff is an unsigned value that specifies the number of frames (0 to - 1).

Sample LoopsThe sample loops field specifies the number Sample Loop definitions in the following list. This value may be set to 0 meaning that no sample loops follow.Sampler DataThe sampler data value specifies the number of bytes that will follow this chunk (including the entire sample LOOP LIST). THIS VALUE IS GREATER THAN 0 WHEN An Application Needs to Save Additional Information. This Value Is Reflected in this Chunks Data Size Value.

List of Sample LoopsA list of sample loops is simply a set of consecutive loop descriptions that follow the format described below. The sample loops do not have to be in any particular order because each sample loop associated cue point position is used to determine the play order The Sampler Chunk is Optional.

OffsetSizeDescriptionValue0x004Cue Point ID0 - 0xFFFFFFFF0x044Type0 - 0xFFFFFFFF0x084Start0 - 0xFFFFFFFF0x0C4End0 - 0xFFFFFFFF0x104Fraction0 - 0xFFFFFFFF0x144Play Count0 - 0xFFFFFFFF

Sample Loop Format

Cue Point IDThe Cue Point ID specifies the unique ID that corresponds to one of the defined cue points in the cue point list. Furthermore, this ID corresponds to any labels defined in the associated data list chunk which allows text labels to be assigned to the various Sample loops.

Typethe Type Field Defines How The Waveform Samples Will Be looped.

ValueLoop Type0Loop forward (normal) 1Alternating loop (forward / backward, also known as Ping Pong) 2Loop backward (reverse) 3 - 31Reserved for future standard types32 - 0xFFFFFFFFSampler specific types (defined by manufacturer)

Loop Type Values

Startthe Start Value Specifies The Byte Offset Into The Waveform Data of The First Sample To Be Played In The LoP.

EndThe end value specifies the byte offset into the waveform data of the last sample to be played in the loop.FractionThe fractional value specifies a fraction of a sample at which to loop. This allows a loop to be fine tuned at a resolution greater than one Sample. The value can range from 0x00000000 to 0xfffffffff. a value of 0 means no fraction, a value of 0x80000000 means 1/2 of a sample length. 0xffffffff is the smallest Fraction of a sample That Can Be represented.

Play CountThe play count value determines the number of times to play the loop. A value of 0 specifies an infinite sustain loop. An infinite sustain loop will continue looping until some external force interrupts playback, such as the musician releasing the key that triggered the wave's Playback. All Other Values ​​Specify An Absolute Number of Times To loop.

Instrument Chunk - "inst" The instrument chunk is used to describe how the waveform should be played as an instrument sound This information is useful for communicating musical information between sample-based music programs, such as trackers or software wavetables This chunk is optional.. And no more Than 1 May Appear in a Wave file.

OffsetSizeDescriptionValue0x004Chunk ID "ltxt" (0x6C747874) 0x044Chunk Data Size70x081Unshifted Note0 - 1270x091Fine Tune (dB) -50 - 500x0A1Gain-64 - 640x0B1Low Note0 - 1270x0C1High Note0 - 1270x0D1Low Velocity1 - 1270x0E1High Velocity1 - 127Instrument Chunk Format

Unshifted NoteThe unshifted note field has the same meaning as the sampler chunk's MIDI Unity Note which specifies the musical note at which the sample will be played at it's original sample rate (the sample rate specified in the format chunk). Fine TuneThe fine tune value specifies how much the sample's pitch should be altered when the sound is played back in cents (1/100 of a semitone). A negative value means that the pitch should be played lower and a positive value means that it should be played at a higher pitch . GainThe gain value specifies the number of decibels to adjust the output when it is played. A value of 0dB means no change, 6dB means double the amplitude of each sample and -6dB means to halve the amplitude of each sample. Every additional / -6dB will double or halve the amplitude again. Low Note and High NoteThe note fields specify the MIDI note range for which the waveform should be played when receiving MIDI note events (from software or triggered by a MIDI controller ). This range does not need to include the Unshifted Note value.Low Velocity and High VelocityThe velocity fields specify the range of MIDI velocities that should cause the waveform to be played. 1 being the lightest amount and 127 being the hardest.

Format VariationsThe down side to the Wave file format's popularity is that out of the hundreds of programs that support it, many abuse or misuse it due to bad programming and / or poor documentation. Once some of these "naughty" programs get fairly popular and churn out millions of incorrect Wave files, the rest of the software industry is forced to deal with it and write code that can read the incorrect files. New code should never write these errors, but possibly read them. Below are a few exceptions that have been made to the strict / original Wave file format.Incorrect Block Alignment value - this can be dealt with by calculating the Block Alignment with the formula mentioned above Incorrect Average Samples Per Second value -. this can be dealt with by calculating the Average Samples Per Second With the form of the us, the us can be done by giving the user a warning when encounted chunk ID's received, is a WARNINGNETERED CHUNK ID's Are Encountered WHERE A One Byte Read Offset Produces A Recognized Chunk ID. this is not a concrete solution, but Will Usually Work Even IF The Program Doesn't Have A CompRensive List of Legal IDs.

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

New Post(0)