Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3:...

90
29Dec'06 Comp30282 Sectn 3 1 University of Manchester School of Computer Science CS3282 : Digital Communications Section 3: Digitising Speech, Music & Video

Transcript of Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3:...

Page 1: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 1

University of Manchester

School of Computer Science

CS3282 : Digital Communications

Section 3: Digitising Speech, Music & Video

Page 2: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 2

3.1 Digitising speech

• Traditional telephone channels restrict speech to 300- 3400 Hz. • Considered not to incur serious loss of intelligibility. • Significant effect on naturalness of sound.

• Once band-limited, speech may be sampled at 8 kHz.

•ITU-T G711 standard for speech in POTS allocates 64000 b/s for 8 kHz sampling rate with 8 bits / sample.

•Exercise 3.1: Why are components below 300 Hz removed?

Page 3: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 3

3.1.1.International standards for speech coding:

• ITU committee CCITT until 1993 part of UNESCO.• Since 1993, CCITT has become part of ITU-T. • Within ITU-T is study group responsible for speech digitisation

& coding standards. •Among other organisations defining standards for telecoms &telephony are:

“TCH-HS”: part of ETSI (GSM). “TIA” USA equivalent of ETSI.“RCR” Japanese equivalent of ETSI. “Inmarsat” & various committees within NATO.

• Standards exist for digitising “wide-band” speech (50 Hz to 7 kHz) e.g. ITU G722 .

Page 4: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 4

3.1.2. Uniform quantisation.

•Quantisation: each sample, x[n], of x(t) approximated by closest available quantisation level. •Uniform quantisation: constant voltage difference ∆ between levels. •With 8 bits, & input range ±V , have 256 levels with ∆ = V/128.•If x(t) between ±V, & samples are rounded, uniform quantisationproduces x’[n] = x[n] + e[n] where −∆/2 ≤ e[n] ≤ ∆/2

• Otherwise, overflow will occur & magnitude of error may >> ∆/2. • Overflow is best avoided.

Page 5: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 5

Noise due to uniform quantisation error

•Samples e[n] “random” within ±∆/2. •When quantised signal converted back to analogue,

adds random error or “noise” signal to x(t).

•Noise heard as sound added to x(t).•Samples e[n] have uniform probability between ±∆/2. It follows that the mean square value of e[n] is:

12311)(

22/

2/

32/

2/

22/

2/

2 ∆=

=∆

=∆

∆−

∆−

∆− ∫∫edeedeepe

Power of analogue quantisatn noise in 0 Hz to fS/2.

Page 6: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 6

3.1.3. Signal-to-quantisation noise ratio (SQNR)

Measure how seriously signal degraded by quantisatn noise.

(dB.) decibelsin power noiseon quantisati

power signallog10 SQNR 10

=

• With uniform quantisation, quantisn-noise power in range 0 to fs/2is ∆2/12 & is independent of signal power.

• ∴ SQNR will depend on signal power.• Amplify signal as much as possible without overflow. • Then, for sinusoidal waveforms with m-bit uniform quantiser:• SQNR ≈ 6m +1.8 dB. •Approximately true for speech also.

Page 7: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 7

Variation of input levels•For telephone users with loud voices & quiet voices,

quantisation noise will have same power.•SQNR better for loud voices than for quiet voices.•If SQNR made acceptable for quiet voices it may be better than

necessary for loud voices.•Useful to know over what dynamic range of input powers the

SQNR will remain acceptable to users.

000

111

001

volts

OK∆ too big for quiet voice

∆ too small for loud voice

Page 8: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 8

3.1.4. Dynamic Range (Dy)

. .

) ( possible log 10 10 dBSQNRacceptablegiveswhichpowerMin

overflownopowersignalMax

Exercise: If SQNR must be at least 30dB to be acceptable, what is Dy assuming sine-waves & 8-bit uniform quantiser? Solution:

= Max possible - Min acceptable SQNR (dB)= (6m + 1.8) - 30 = 49.8 - 30 = 19.8 dB.

Too small for telephony

Exercise: Repeat this calculation for 12-bit uniform quantisation.

Page 9: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 9

3.1.5. Instantaneous companding•Eight bits per sample not sufficient for good speech encoding with uniform quantisation.

•Problem lies with setting a suitable quantisation step-size ∆.

•If ∆ too large, small signal levels will have SQNR too low

•If ∆ too small, large signal levels distorted due to overflow.

•One solution is to use instantaneous companding

•Step-size adjusted according to amplitude of sample.

•For larger amplitudes, larger step-sizes used as illustrated next.

•‘Instantaneous’ because step-size changes from sample to sample.

Page 10: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 10

Non-uniform quantisation used for companding

Fig. 3.1

x(t)

t 001 111

Page 11: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 11

Analogue implementation of companding

•Pass x(t) thro’ compressor to produce of y(t).• y(t) is quantised uniformly & transmitted or stored as {y’[n]}. •At receiver, {y’[n]} DAC converted & passed thro’ expander• Expander reverses effect of compressor.•Analog implementation uncommon but shows concept well.

y’(t){y’[n]} x’(t)y(t) ADC withuniformquantiser

x(t) Expand-er

Com-pressor

UniformDACTransmit

or store

Page 12: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 12

Digital implementation of companding

• x(t) sampled & digitised with high word-length (say 12 or16 bits)• Each x[n] passed thro’ compressor to produce of y[n].• Each y[n] truncated to required word-length (say 8 bits)• {y’[n]} transmitted or stored. • At receiver, each y’[n] passed thro’ expander which reverses

effect of compressor to give x’[n].•{x’[n]} may be DAC converted with 12 or 16 bit wordlength.

Com-pressor

Uniformquantiser

Ex-panderx(t)

{y[n]}

Transmitor store

16-bit ADC

{x[n]}16-bitDAC

{y’[n]} {x’[n]}x’(t)

Page 13: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 13

Uniformly quantising a digital signal

• If a signal is digitised with uniform quantisation at 16 bits/sample, it can be further quantised (uniformly) to 12 bits by shifting right and discarding the ‘carry out’ bits.

• Equivalent to dividing by 16 & taking integer part.

Page 14: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 14

‘A-Law’ instantaneous companding

Common compressor is linear for |x(t)close to zero & logarithmic for larger values. A suitable formula is:

>≥

+

≤=

AV |x(t)| V : V

|x(t)|logK11sign(x(t))

AV |x(t)| : (KV)

Ax(t)

y(t)e

where K = 1+ loge (A) A is constant which determines cross-over between linear & log.

Page 15: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 15

Mapping from x(t) to y(t) by A-law companding

x(t)

y(t)

+VV/A−V −V/A

1

−1

1/K

−1/K

A ≈ 3

Page 16: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 16

A-law mapping again

y(t)

x(t)+V

-VV/A

-V/A

-1

1

1/K

-1/KA ≈ 13(Too difficult to draw if A is any larger)

Page 17: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 17

G711 standard ‘A-law’ companding with A=87.6

•A-law companding as used in UK with A = 87.6 & K=5.47.• General formula becomes:

>≥

+

≤=

87.6V |x(t)| V : V

|x(t)|log183.01sign(x(t))87.6

V |x(t)| : 16x(t)/Vy(t)

e

• ≈1 % of domain of x(t) linearly mapped onto ≈20 % of range of y(t).

• Remaining ≈99% of domain of x(t) logarithmically mappedonto ≈80% of range for y(t).

Page 18: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 18

Effect of compressor on sine-wave

t

V

x(t) y(t)

1

-V -1

t

Page 19: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 19

Effect of compressor on triangular wave

t

V

x(t)

-V

y(t)

1

-1

Page 20: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 20

A-law expander formula

≤<≤

= − 1 |(t)y| 1/K : (t))Veysign(1/K |(t)y| : (t)/A yVK

(t)x ) 1 (t)|y | (K

Page 21: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 21

Graph of A-law expander formula

y(t)

x(t)+V

-V

V/A-V/A

-111/K

-1/K

A ≈ 3

Page 22: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 22

Effect of expander on ‘small samples’

• Without quantisation, passing y(t) thro’ expander would produce original signal x(t) exactly.

• ‘Small’ samples reduced by factor 16 (when A=86.6). • Small changes affecting these samples are also divided by 16.• Reduces changes due to quantisation by factor 16. • Increases the SQNR for ‘small’ samples by 16 dB as:

20log10(1/16) = -20 log10(24) = -80log10(2) ≈ -80x0.3 = -24

Page 23: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 23

Effect of expander on ‘large’ samples

• If y(t) increasing by ∆y causes x(t) to increase by ∆x,

∆x/∆y ≈ dx(t)/dy(t)

• Therefore ∆x ≈ (dx(t)/dy(t)) ∆y

• dy(t)/dx(t) is ‘quantisation step amplification factor’

Page 24: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 24

Quantisation step amplification factor

Differentiating (see notes) gives:

≤<≤

=V |x(t)| V/A : Kx(t)

V/A |x(t)| :VK/A

dy(t)dx(t)

in general and when A=87.6,

≤<≤

=V |x(t)| V/A : 5.47x(t)

V/A |x(t)| : V/16

dy(t)dx(t)

Page 25: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 25

Quantisation step amplification factor

V/A +Vx(t)

KV

-KV

-V KV/A

dx(t)/dy(t)

For |x(t)|<V/A amplification constant at KV/A (=16).

For |x(t)|>V/A increases in proportion to x(t).

Page 26: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 26

Observations from amplification graph

• For |y(t)| > 1/K, expander causes quantisation step to increase in proportion to x(t).

• Quantisation noise gets louder as the signal gets louder. • If all samples of x(t) ‘large’, SQNR would remain approximately the

same, i.e. about 36 dB for G711 (see next slide)• If 30 dB SQNR acceptable, large signals are quantised satisfactorily.• Small signals quantised satisfactorily for lower amplitudes. • Largest amplitude unchanged & smallest reduced by factor 16.• Dy increased by factor 16 i.e. 24 dB to 19.8+24 = 43.8 dB• Same as 12-bit linear (6x12+1.8 – 30) but with only 8 bits.• Quantisation error for A-law worse than for uniform when |x(t)| > V/K• Price to be paid for the increased dynamic range.

Page 27: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 27

Variation of SQNR with amplitude of sample

48

36

24

12

VV/2V/4V/16 3V/4

A-law

Uniform

Amplitudeof sample

0

SQNR dB

Page 28: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 28

Mu (µ)-law companding

•Similar companding technique adopted in USA.

( ) lly_used255_genera (mu) µ )µ 1 (log

) /Vx(t)µ 1 (logx(t)signy(t)

e

e =

+

+=

•When |x(t)| < V / µ , y(t) ≈ ( µ / loge(1+µ) )x(t)/V since loge(1+x) ≈ x − x2/2 + x2/3 - … when |x| < 1.

∴µ-law with µ = 255 is like A-law with A=255,though transition from small quantisation-steps for small x(t) to larger ones for larger values of x(t) is more gradual with µ-law.

Page 29: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 29

Implementing compressor & expander

• Compression/expansion may be done digitally via ‘look-up’ table. • x[n] assumed to be 12-bit integer in range -2048 to 2047.• Digitise x(t) by 12-bit ADC, or use 16-bit ADC & truncate to 12 bits.• For each 12-bit integer, table has corresponding 8-bit value of x(t). • Expander table has a 12-bit word for each 8 bit input. • Each 8-bit G711 ‘A-law’ sample is a sort of ‘floating point number:

S X2 X1 X0 M3 M2 M1 M0

x m

Value is (-1)S+1 . m . 2x-1 where the ‘mantissa m is:(1 M3 M2 M1 M0 1 0 0 0)2 if x>0

or (0 M3 M2 M1 M0 1 0 0 0)2 if x=0

Page 30: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 30

3.2.Further reducing bit-rate for digitised speech

•PCM encodes each speech sample independently & is capable of

encoding any wave-shape correctly sampled.

•This is ‘waveform encoding’: simple but needs high bit-rate.

•Speech waveforms have special properties that can be exploited

by ‘parametric coding techniques’ to achieve lower bit-rates.

Page 31: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 31

Properties of speech waveforms• General trends may be identified allowing one to make estimatesas to which sample value is likely to follow a given set of samples. • Makes part of information transmitted by PCM redundant • Speech has 'voiced' & 'unvoiced' parts i.e. 'vowels' & 'consonants'. •Predictability lies mostly in voiced speech, & these are loudest. •Voiced speech has periodicity.• ’Characteristic waveform', like a decaying sine-wave, repeated

periodically (or approximately so).

t

Volts

Page 32: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 32

A characteristic waveform for voiced speech

Volts

t

Page 33: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 33

Voiced speech (continued)•Shapes of characteristic waveforms to some extent predictable

from first few samples. •Also, once one characteristic waveform has been received,

next one can be predicted. •Prediction not 100% accurate & "prediction error" sent.

•Sending predictn error more efficient than sending whole signal.

•Decaying sine-wave shape of each characteristic waveform is

due to the way sound is 'coloured' by shape of mouth.

•Similarity of repeated characteristic waveforms due to

periodicity of sound produced by vocal cords.

Page 34: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 34

Unvoiced speech:

• Random or noise-like with little periodicity.

• Lower in amplitude than voiced telephone speech & exact shape

of its noise-like waveform not critical for perception

•Almost any noise-like waveform will do as long as energy level

is correct, i.e. it is not too loud or too quiet.

•Easier to encode than voiced if we separate them at transmitter

& encode them in separate ways.

Page 35: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 35

Characteristics of speech & perception exploited to reduce bit-rate

1. Higher amplitudes may be digitised less accurately.2. Adjacent samples usually close in value.3. Voiced characteristic waveforms repeat quasi-periodically 4. Predictability within characteristic waveforms.5. Unvoiced telephone speech quieter than voiced & exact wave-

shape not critical for perception.6. Pauses of about 60 % duration per speaker.7. Ear insensitive to phase spectrum of telephone speech 8. Ear more sensitive in some frequency ranges than others.9. Audibility of low level frequency components 'masked' by

adjacent higher level components,

Page 36: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 36

Section of voiced & unvoiced speech.Large amplitudes are voiced.

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 -1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1 x 10

4

Time (s)

Ampli

tude

Page 37: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 37

Small section of female voiced speech

This was extracted from previous graph.

0 500 1000 1500 2000 2500 3000 3500-8000

-6000

-4000

-2000

0

2000

4000

6000

8000

10000

Page 38: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 38

Smaller section of male voiced speech.

0 500 1000 1500-2

-1.5

-1

-0.5

0

0.5

1

1.5

2x 104

Page 39: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 39

Magnitude spectrum of male speechObtained by FFT analysing about 4 cycles as shown on next slide

0 0.5 1 1.5 2 2.5 3 3.5 46

7

8

9

10

11

12

13

14

Page 40: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 40

Section of male voiced speech

0 100 200 300 400 500 600 700-1.5

-1

-0.5

0

0.5

1

1.5

2x 104

Page 41: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 41

3.2.2. Differential coding

• Encode differences between samples.

• Where differences transmitted by PCM this is ‘differential PCM’.

Page 42: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 42

3.2.3. Simplified DPCM coder & decoder

Delay by1 sample

Quantisers[n] e[n]

Transmit or store samples

s[n-1]

e[n] = e[n] + q[n]

Coder

DecoderDelay by1 sample

s[n-1]

Receive fromchannel or store

e[n]][ˆ ns

Page 43: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 43

Simple DPCM receiver

][ˆ ns

PCMreceiver

Delay by1 sample

s[n-1]

Receive e[n]

Page 44: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 44

Why is speech is well suited to differential coding?

• Speech energy biased towards low frequency end of spectrum.

• Especially true for voiced, (not so much for unvoiced)

• Adjacent speech samples often quite close

• As energy of {e[n]} < energy of {s[n]}{e[n]} encoded using fewer bits/sample.

Page 45: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 45

Modify simple DPCM diagram in 2 ways

Receiver: introduce α with α=0.99.

Transmitter: derive as at the receiver. ^

Instead of s[n] - s[n-1] , transmit s[n] - α s[n-1] .

][ˆ ns

Page 46: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 46

Modified DPCM encoder

--

α

αz-1

z-1

Quantise

Copy of receiver

e[n]

e[n]s[n]

s[n]^

^

Page 47: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 47

Practical DPCM encoder

Previous diagram simplifies to:

α

z-1

Quantisee[n]s[n]

s[n]

e[n]

^

^

Page 48: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 48

32 kb/s ADPCM

• DPCM with adaptive quantiser(adapts its step-size according to signal e[n] )

• ITU standard for speech coding (G726)(also for 40, 24 & 16 kb/s)

Page 49: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 49

3.2.4. Linear prediction coding (LPC)

• Concept of differential coding described in terms of prediction.• Consider again a differential quantiser as shown below:

s[n]

s[n-1]

Quantiser e[n]

s[n] z -1 Prediction

Prediction error e[n]

Page 50: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 50

Prediction• Predict that s[n] will be identical to s[n-1]. • Prediction error (residual) will be {e[n]}. • If prediction good, {e[n]} small & fewer bits needed for it.• Better prediction from several previous samples:

+ + +

+ s[n]

s[n]

b1 b2 b3 bM

z-1 z-1 z-1

z-1

e[n]

Prediction

Page 51: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 51

Short term linear prediction (LP) filter (for analysis)

• FIR digital filter of order M with coeffs b1, b2, ..., bM . • Must be adaptive,• New set of coeffs for each block of 10 or 20 ms.• Code and transmit e[n] & coeffs b1, b2, ..., bM for each block.•Typically M=10.

Page 52: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 52

LPC decoder• Receiver reconstruct speech s[n] as follows:

+ + +

+ s[n]

b1 b2 b3

z-1 z-1 z-1 z-1

e[n]

Prediction

bM

• Prediction filter now used recursively for ‘synthesis’

• Puts back what was removed at transmitter

Page 53: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 53

Comments on LPC coder/encoder

•M between 6 &12. •Error {e[n]}, has special properties which allow it to be coded

very efficiently. •Study human speech production mechanism.

Page 54: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 54

Human speech production mechanism•For vowels, air forced thro’ vocal cords & causes them to vibrate.• Periodic build-up & release of pressure produces sound.• "Vocal tract excitation".• If high-pass filtered, would appear as a series of pulses:

Mouth

Nose

Air from lungs

Vocal cords

Vocal tract

Velum

T Time

High -pass filtered excitationVolts

Speech-likewaveform

Time

Page 55: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 55

Unvoiced speech (consonants)

• For unvoiced speech, vocal cords do not vibrate. • Turbulent air flow produces “hissing” sound. • Random or noise-like vocal tract excitation.

Page 56: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 56

Formants in speech

• Excitation passes thro' vocal tract. • Flexible tube : begins at glottis & ends at lips. • Shape determined by tongue, jaw & lips.• "Nasal tract" also tube connected at "velum".

• Tubes act like a filter with resonances ("formants").• Resonances change as person speaks. • Resonance at f1 Hz emphasises power close to f1. • Amplitudes of some harmonics increased with respect to others.• Refer back to speech graphs (slide 39). We see this effect.

Page 57: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 57

Effect of prediction filter at transmitter

With correctly adapted coeffs: prediction (analysis) filter at transmitter removes resonances (formants).

Remaining ‘prediction error’ (or ‘residual’) signal {e[n]} becomes high-pass filtered excitation signal:

• periodic series of pulses (voiced), or

• spectrally white random signal (unvoiced).

Spectrum of {e[n]} should now be flat. No formants.

All harmonics with same amplitude

Page 58: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 58

Voiced speech {s[n]} & residual {e[n]} with spectra

e[n]

nP P P

s[n]

P P P

n

f

f

|S(..)|

|E(..)|

1/P

Page 59: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 59

Deriving short term prediction coeffs b1, b2, …, bM

• DSP procedure: “LP(C)” analysis.

• Takes block of say 160 samples of speech (≈20 ms).

• Coeffs calculated such that energy of {e[n]} minimised.

•In MATLAB given an array s of say 160 speech samples:b = lpc(s, 10);

• Produces an array containing 1, b1, b2, ..., bM with M=10

Page 60: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 60

‘LPC-10’

• Once b1 , b2 , ..., b M derived by LPC analysis, {e[n]} may be obtained by passing speech thro' analysis filter• In MATLAB: e = filter(b, 1, s);

• LPC-10 codes 20 ms speech frames in the form of:Ten LPC filter coeffs (about 40 bits say)A ‘stylised’ representation {e[n]} consisting of:

(i) Unvoiced/voiced decision (1 bit)(ii) Amplitude ( a single number: 8 bits say)(iii) A pitch-period (a single number: 8 bits say)

• Total, about 57 bits/frame, 50 frames/s i.e. 2850 bit/s

• LPC-10 coder at 2400 b/s is widely used in military comms.

Page 61: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 61

LPC-10 receiver

LPC ‘synthesis’ filter

Coefficients

Speech

{e[n]}Noise generator

Impulsesequencegenerator

Pitch-period P

V/UV decisionAmplitude

Page 62: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 62

Demo in MATLAB

• A simple LPC-10 coder may be written and tested in MATLAB.• We know how to derive the filter coeffs and the prediction error

for a segment of speech.• To make things really easy, forget about unvoiced speech and

use a fixed frequency excitation signal consisting of a series of pulses at intervals of say 80 samples.

• Only the LP filter coeffs and the energy of {e[n]} per 160 sample frame need be transmitted or stored.

• Forget about quantising filter coeffs.

Page 63: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 63

3.2.5. Waveform coding and parametric coding.

•Waveform coding techniques such as PCM & DPCM try to preserve exact shape of speech waveform as far as possible. •Simple to understand & implement, but cannot achieve very low bit-rates. •Parametric techniques (e.g. LPC) do not aim to preserve exact wave-shape, & represent features expected to be perceptually significant by sets of parameters,• i.e. bi coefficients & parameters of stylised error signal.• Parametric coding more complicated to understand & implement than waveform coding, but achieves lower bit-rates.

Page 64: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 64

3.2.6. Regular pulse excited LPC with LTP : (RPE-LTP)

•Original speech coding technique for GSM: “GSM 06.10”. •One of many LPC techniques for mobile telephony.•Relatively simple by today’s standards. (CELP)•Its bit-rate is 13 kb/s. •Produces 260 bits for each 20 ms block of speech. •Channel coding adds 196 bits to produce 456 bits per block & overall bit-rate of 22.8 kb/s. •LPC to calculate short term prediction coeffs & {e[n]}.•Does not adopt “stylised” description of {e[n]}. •Employs “long term predictn (LTP) filter”.•Cancels out periodicity due to vibration of vocal cords.

Page 65: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 65

Long term predictor (LTP)

Delay of P samples

e[n]

K

e[n] with periodicity removed

Most of the periodicity removed to leave a lower-amplitude noise-like residual.

Multiplier K is applied to compensate for signal getting slightly louder (K<1) or softer (K>1).

Page 66: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 66

Encoding the RPE-LTP residual

• LTP residual encoded “regular pulse excitation” coding.• Divides each 160 sample block into four ‘40 sample’ sub-blocks. • Each sub-block divided into 3 interleaved sets of locations : • {1,4,7,..., 37,40}, {2,5,8,...38}, {3,6,9,12,...39} referred to as ‘tracks’.• Find track with most energy & encode choice with 2-bits. • The 13 samples are quantised with 3-bit per sample & a 6-bit overall

scaling factor. • At receiver, residual is decoded & applied to inverse LTP. • Resulting periodic signal e[n] then becomes input to short-term inverse

LPC filter.

Page 67: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 67

RPE-LTP receiver

Fig 8.17

e[n] with periodicity removed

Delay of P samples

e[n]

K

Short term LPC inverse filter

Speech

Coeffs

P

K

Page 68: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 68

3.2.7. CELP• Based on similar principles to RPE-LRP.• Has short & long term predictor to produce low level noise-like residual. • Uses ‘analysis by synthesis’ to encode residual . • Has 2 identical code-books, one at transmitter & one at receiver.• Codebooks contain duplicate segments each 40 samples long. • Each codebook has M-bit index where M may be 10.• 1024 ‘40-sample’ sequences, indexed 0, 1, ..., M-1. • Transmitter splits residual into four ‘40-sample’ sub-segments.• Tries each code-book entry to find best one to use as excitation.• Index of best entry transmitted. • Four indices transmitted for each 160 sample block of residual.

Page 69: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 69

Analysis-by-synthesis• Transmitter has copy of receiver. • For a 40 sample sub-segment, it applies each codebook entry to the long & short

term synthesis filters to synthesise speech as it would be synthesised at receiver.• It then compares shape of synthesised waveform with original speech. • Similarity is measured by computing a cross-correlation function. • Compares two sequences where the amplification of one is optimised to make

them as close as possible. • NB. k can be made negative.• We are comparing their ‘shapes’ not their magnitudes . • In CELP coders, the cross-correlation is weighted to take into account some

characteristics of human sound perception, i.e. it is ‘perceptually weighted’.• Codebooks may be populated with samples of pseudo-random noise. • More recent versions of CELP use ‘algebraic’ code-book entries.

Page 70: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 70

A simplified view of CELPDerive LPC filter coeffs

Find fundamental (pitch) frequency

Construct excitation from codebook entry & long term predictor

LPC synthesis filter

Compute cross-correlation to measure similarity

Control codebook search to maximize similarity.

Apply perceptual weighting

Speech

Trans-mit

Transmitresults of search

Page 71: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 71

3.2.8. Algebraic CELP (G729)

• Instead of being read from a code-book, each excitation is constructed by positioning a suitable number of +ve or −ve unit impulses within the sub-segment.

• Search made among a range of possible impulse positions.• Suitability of each one evaluated by comparing synthesised with original speech. • Each sub-segment divided into five interleaved sets of possible pulse locations :

{1,6,11,16,21,26,31,36}, {2,7,12,17,22,27,32,37}, …, {5,10,15,20,25,30,35,40} referred to as ‘tracks’.

• Position one +ve or -ve unit impulse per track within 1st 3 tracks & 4th or 5th.• Must choose best possible positions & polarities for these impulses. • ‘Best’ means max cross-correlation between synthesized & original speech. • Recording 4 unit-impulse positions with polarities & the choice of tracks requires

17 bits per sub-segment.

Page 72: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 72

3.3. Digitising music:

• Standards exist for the digitisation of ‘audio’ quality sound.• Compact disks: 2.83 megabits per second.

(fs= 44.1kHz, 16 bits/sample, stereo, with FEC.)• Too high for many applications.• DSP compression takes advantage of human hearing. • Compression is “lossy”, i.e. not like “ZIP” . • MPEG concerned with hi-fi audio, video & their synchronisation.• DAB, MUSICAM use “MPEG-1 audio layer 2”. • 3 MPEG layers offer range of sampling rates (32, 44.1, 48 kHz)

& bit-rates from 224 kb/s to 32 kb/s per channel. • Difference lies in complexity of DSP processing required .

Page 73: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 73

MPEG1-4 with MP3 etc

•Layer 1 of MPEG-1 (MP1) simplest & best suited to higher bit-rates: e.g. Philips digital compact cassette at 192 kb/s per channel.

• Layer 2 has intermediate complexity & is suited to bit-rates around128 kb/s: DAB uses MP2.

• Layer 3 (MP3) is most complex but offers best audio quality.Can be used at bit-rates as low as 64 kb/s: Now used for distribution of musical recordings via Internet.

• All 3 MPEG-1 audio layers simple enough to be implemented on asingle DSP chip as real time encoder/decoder.

•MPEG-2 supports enhanced & original (MPEG-1) versions of MP1-3.•MPEG-3 was started but abandoned.

Don’t confuse MPEG-3 with MP3 (MPEG-1/2 audio level 3)•MPEG-4 ongoing & introduces ‘AAC’ & ‘MP4’.

Page 74: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 74

Introduction to MP3

CD recordings take no account of the nature of the music and music perception.

Frequency masking & temporal masking can be exploited to reduce bit-rate required for recording music. This is ‘lossy’ rather than ‘loss-less’compression.

Frequency masking: ‘A strong tonal audio signal at a given frequency will mask, i.e. render inaudible, quieter tones at nearby frequencies, above and below that of the strong tone, the closer the frequency the more effective the matching’.

Temporal masking: ‘A loud sound will mask i.e. render inaudible a quieter sound occurring shortly before or shortly after it. The time difference depends on the amplitude difference’.

Page 75: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 75

Perceived loudness

• Human ear is not equally sensitive to sound at different frequencies.

• Most sensitive to sound between about 1 kHz and 4 kHz. • ‘Equal loudness contour graphs’ reproduced below. • For any contour, human listeners find sound equally loud

even though actual sound level varies with frequency. • The sound level is expressed in dB_SPA (see notes)

Page 76: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 76

Equal loudness countours

Page 77: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 77

MP3 sub-bands• MP3 is a frequency-domain encoding technique.• Takes 50% overlapping frames of either 1152 or 384 samples. • With fs = 44.1 kHz : 26.12 ms or 8.7 ms of music • Sound split into frequency sub-bands. • Splitting in 2 stages, firstly by bank of 32 FIR band-pass filters. • Output from each filter down sampled by a factor 32.• Then further split by means of DCT• Obtain 1152 or 384 frequency domain samples.

Page 78: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 78

Frequency domain coding

• Frequency-domain samples can be coded. • Spectral energy may be found to be concentrated in certain

frequency bands and may be very low in others. • Assign more bits to some frequency-domain samples than others. • Equal loudness contours useful here. • Use ‘signal to masking’ (SMR) ratio at each frequency to

determine number of bits allocated to the spectral sample.• More significant advantages from ‘psycho-acoustics’.

Page 79: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 79

Frequency masking

• ‘A strong tonal audio signal at a given frequency will mask, i.e. render inaudible, quieter tones at nearby frequencies, above and below that of the strong tone, the closer the frequency the more effective thematching’.

• Characterised by a ‘spreading’ function,• Example given for a strong tone (60 dB_SPL) at 1kHz.

Page 80: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 80

Example of spreading function

2000500 1000f Hz

60

40

20

dB_SPL

2000500 1000 f Hz

60

40

20

dB_SPL

Represents a threshold of hearing for frequencies adjacent to the tone.

A tone below the spreading curve will be masked & not heard.

Tones make masking threshold contour different from ‘in quiet’.

Page 81: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 81

Effect of 2 strong tones on masking contour

2020 k

5k1k

f Hz

10k100

60dB_SPL

0

•Allocate bits according to SMR relative to this masking contour,•More efficient & economic coding scheme is possible.•Calculated by FFT.

Page 82: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 82

Temporal masking

• ‘A loud sound will mask a quieter sound occurring shortly before or shortly after it. The time difference depends on the amplitude difference’.

• Effect of frequency masking continues for up to 200 ms after the strong tone has finished, and even before it starts.

• Frequency masking contour for a given frame should be calculated taking account previous & next frames

Page 83: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 83

Temporal characteristic of masking by a 20 ms tone at 60 dB_SPL.

0 200 400

t (ms)

-50

60

dB_SPL

20

40

simultaneous Post-masking

Pre-

Page 84: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 84

Diagram of an MP3 coderMusic

Transform to frequency domain

Derive psychoacoustic masking function

Devise quantsationscheme for sub-bands according to masking

Apply Huffman coding

Page 85: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 85

Huffman coding & more detail

• Quantisation scheme tries to make the ∆2/12 noise < masking threshold. • Non-uniform quantisation is used. • Further efficiency with Huffman coding (lossless) • ‘Self terminating’ variable length codes for the quantisation levels.• Quantised samples which occur more often given shorter wordlengths. • MP3 decoder simpler than encoder• Reverses quantisation to get frequency domain samples & • Transforms back to time domain taking into account frames are 50%

overlapped.• Some more detail about MP3 compression and Huffman coding is given

in references quoted in the Comp30192 web-site.

• Frequency masking demo: www.ece.uvic.ca/~aupward/p/demos.htm.

Page 86: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 86

3.4. Digitisation of Video

• Digital TV with 486 lines would require 720 pixels per line,each pixel requiring 5 bits per colour, i.e.≈ 2 bytes per pixel.

• At 30 frames/s, bit-rate ≈ 168 Mb/s or 21 Mbytes/s. • Normal CD-Rom would hold 30 s of TV video at this bit-rate. • For HDTV, requirement is about 933 Mb/s• For film quality, required bit-rate ≈ 2300Mb/s. • SVGA screen with 800x600 pixels requires 3 x 8 = 24 bits per

pixel, & 288 Mb/s if refreshed at 25Hz with interlacing. • Need for video compression is clear.

Page 87: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 87

• MPEG-1 & 2 & FCC standard for HDTV use “2-D discrete cosine transform (DCT)” applied to 8 x 8 (or 10x10) pixel “tiles”. • Red, green & blue colour measurements for each pixel transformed to a “luminance” & 2 “chrominance” measurements.• The eye is more sensitive to differences in luminance than to variations in chrominance. • Three separate images dealt with separately. •For chrominance, average sets of 4 pixels to produce fewer pixels. • Apply DCT to each tile to obtain 8x8 (or 10x10) 2-D frequency domain samples starting with a sort of “dc value” which represents overall brightness of the “tile”. • Finer detail added by higher 2-D frequency samples. • Just as for 1-D, higher frequencies add finer detail to signal shape.

Page 88: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 88

• The 2-D frequency-domain samples for each tile now quantisedaccording to perceptual importance.

• Accurately quantise differences betw dc values of adjacent tiles. • Differences often quite small & need few bits. • Remaining DCT coeffs for each tile diminish in importance

with increasing frequency.• Many are so small that they may be set to zero.• Runs of zeros easily digitised by recording length of run. • Further bit-rate savings achieved by Huffman coding.• Assigns longer codes to numbers which occur less often.• Shorter codes for commonly occurring numbers.

Page 89: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 89

•Technique above may be applied to a single video frame•Used to digitise still pictures according to “JPEG” standard. •MPEG-1 & 2 send JPEG encoded frames ( I-frames) about once or twice per second. •Between the I-frames MPEG-1 &-2 send

“P-frames” which encode differences between current frame& previous frame

“B-frames” which encode differences between currentframe the previous & the next frame.

• MPEG-1 originally for encoding reasonable quality video at about1.2 Mb/s.

• MPEG-2 originally for encoding broadcast quality video at bit-rates between 4 & 6 Mb/s.

Page 90: Section 3: Digitising Speech, audio & videobarry/mydocs/CS3282/Slides/DCS06_3.pdf · Section 3: Digitising Speech, Music & Video. 29Dec'06 Comp30282 Sectn 3 2 3.1 Digitising speech

29Dec'06 Comp30282 Sectn 3 90

End of section 3.