Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

9
Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University

Transcript of Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

Page 1: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

Anatomy of a Sound File

v12.7.17

© Allan C. MilneAbertay University

Page 2: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

What is a sound file ?

• A saved digital wave form containing the sample values.

• A long stream of 1’s and 0’s

• So the file must have an encoding and structure allowing a correct interpretation of the binary data in rebuilding the digital wave form.

Page 3: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

Some Common Encodings.• Here are some audio file encoding

standards:– WAV (.wav)– AIFF (.aif, .aiff)– AIFC (.aic, .aifc)– AUN (.au, .snd(– REAL (.ra)– MPEG (.mpa, .mp2, mp3)– FLACC– LIQUID (.la1)

Page 4: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

File Headers.

• Provides information on the format of the data within the file; this might include– Name of sound clip– File size– Playback duration– Number of channels– Resolution– Sampling rate– Compression information– And more …

Page 5: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

WAV File Format.

• The native audio file format used by Windows.

• Overall structure based on IFF (Interchange File Format)– Developed by EA for the Amiga.

• Microsoft then developed RIFF (Resource Interchange File Format).

• A WAV file is a RIFF file.

Page 6: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

RIFF Files.

• Organised as a collection of nested chunks.

• Tags identify the contents of each chunk.

• File should start with– 4 characters = 'RIFF'.– 4 byte chunk size (= file length -8).– 4 character type code = 'WAVE'.

Page 7: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

RIFF Chunk Format.

• 4 character identification tag– E.g. 'RIFF', 'fmt ', 'LIST', 'data'.

• 4 byte chunk size (less 8).• Chunk data …

RIFF size WAVE

RIFF chunk

fmt size ………

fmt chunk

LIST size INFO

LIST chunk

Page 8: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

WAV Format (fmt) Header.• Defines the properties of the sample data

and hence how to reproduce the original sound.

– Formatting (2 bytes) = 1 for PCM.– # of channels (2 bytes).– Sampling rate (4 bytes).– Average # of bytes per second (4 bytes).– # of bytes for 1 sound point (2 bytes).– # of bits per sample (2 bytes).

• See WaveFormat.doc for a fuller definition.

Page 9: Anatomy of a Sound File v12.7.17 © Allan C. Milne Abertay University.

The Sampled Data.

• Samples are stored in a 'data' chunk.• Irrespective of sample size (in bits), the

samples are always stored in complete bytes.

• Sample size & interpretation:– <= 8 bits unsigned integer– > 8 bits signed integer

• Samples for all channels at a specific time index are stored together in channel order.