Sampled Audio - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Sampled Audio

Description:

As described before, the audio signal is sampled at some sampling rate fs. ... Change the sampling frequency. Listen to the effect and examine in Winhex. ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 17
Provided by: Malcolm139
Category:

less

Transcript and Presenter's Notes

Title: Sampled Audio


1
Sampled Audio
2
Sampled Audio
  • We store digitised audio samples.
  • This is the main audio data.
  • In a file (e.g. .wav format) we also need some
    header information.
  • We will look at the headers and data.
  • Then we will modify the audio data.

3
Sampled Audio
  • As described before, the audio signal is sampled
    at some sampling rate fs.
  • If we sample at fs samples per second how many
    samples will we need to represent 2 seconds of
    audio?
  • What if it is stereo?

4
Sampled Audio
  • Also, we must decide on some level of
    quantisation or bits per sample nbits.
  • Total bit rate is therefore
  • nbits x fs bits per second.
  • After deciding on some coding scheme (audio
    signal is biplolar) we store the numeric
    representation of the samples sequentially.

5
The wav format
  • Found in Microsoft environments.
  • Consists of a RIFF header.
  • Broken into chunks and subchunks.
  • Chunks (and subchunks) have
  • label of chunk
  • Size of chunk
  • Then the chunk itself (body)
  • wav file always has
  • RIFF chunk
  • Fmt subchunk
  • Data subchunk

6
The RIFF header
  • Byte 1 - 4 RIFF
  • Type of file in ASCII
  • Byte 5 - 8 00 01 7A F0 9700810
  • Size of file from byte 9 onwards
  • Byte 9 12 WAVE
  • Form of data in ASCII
  • Byte 13 - 16 fmt
  • Format in ASCII (note the space after fmt)
  • Byte 17 - 20 00 00 00 10 1610
  • Size in bytes of the format information
  • Byte 21 - 22 00 01 110
  • Code (1 represents Microsoft PCM)

7
The RIFF header
  • Byte 23 24 00 02 210
  • Number of channels
  • Byte 25 28 00 00 56 22 2205010
  • Samples per second
  • Byte 29 32 00 01 58 88 8820010
  • Average bytes per second
  • Byte 33 34 00 04 410
  • Block alignment
  • Byte 35 35 00 10 1610
  • Bits per sample
  • Byte 36 - 39 data
  • Indicates the start of the data block in ASCII
  • Byte 40 43 00 01 7A 9C 9692410
  • Size in bytes of the data

8
Block Alignmentin this example
Sample 1 Sample 1
Byte 1 Byte 2 Byte 3 Byte 4
Channel 0 Low byte Channel 0 High byte Channel 1 Low byte Channel 1 High byte
9
Format codes for audio data
  • 0x0001
  • Microsoft pulse-code-modulation (PCM) format
  • 0x0101
  • IBM m-law format
  • 0x0102
  • IBM a-law format
  • 0x0103
  • IBM AVC adaptive differential PCM format

10
Other possible subchunks
  • Fact chunk
  • This gives information about the file which is
    particularly useful for other formats, for
    example where the data is compressed. In PCM this
    is not required.
  • Cue chunk
  • The cue chunk identifies points in the data
    stream.
  • Playlist chunk
  • Gives the order in which the data is to be played
    using the cue points.
  • Associated data chunks
  • Other information that you might want stored such
    as text.

11
Examination in Winhex
  • Look at chord.wav in Winhex.
  • Find the start and end of the
  • Riff chunk
  • Fmt subchunk
  • Data subchunk
  • Why does the end of the Riff chunk not correspond
    to the end of the data subchunk?
  • More subchunks?

12
Examination in Winhex
  • Determine the sampling frequency.
  • Change it.
  • Estimate how long the sound will play for.
  • Double that time using Winhex.
  • How many bits are used per sample? (nbits)

13
Sound file handling using Matlab
  • Use wavread to retrieve audio data.
  • sndwavread(chord.wav)
  • sound , fs, bitswavread(chord.wav)
  • Are the number of bytes returned as expected?
  • What is the sampling rate and the number of bits
    per sample.

14
Sound file handling using Matlab
  • Use wavwrite to save audio data.
  • wavwrite(snd, chord.wav) (simplest)
  • See Matlab help for more options
  • Use sound(snd) to play sound.

15
Matlab Exercises
  • Change the sampling frequency.
  • Listen to the effect and examine in Winhex.
  • Remove part of the sound using the Matlab
    operator.
  • Play one channel of the stereo sound using array
    indexing.
  • Join two sounds together
  • NewsoundA(startend) ,B(startend)

16
Matlab Exercises
  • Change the volume by multiplication/division.
  • Mix two sounds together. (Must be of the same
    length)
  • Add echo to the sound, by starting a lower level
    version a bit later.
  • Invent your own effects.
Write a Comment
User Comments (0)
About PowerShow.com